Re: Faster than fso.Folder?

Date : Mon, 11 Jul 2005 11:30:44 -0400
To : XSI(at)Softimage.COM
From : Patrick Boucher <patrickb(at)buzzimage.com>
Subject : Re: Faster than fso.Folder?
brad wrote:
Anybody know a faster way to get a list of subdirectories in jscript than using the fileSystemObject?
Using the following example lifted directly from the msdn docs:

var fso, f, fc, s;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.GetFolder(folderspec);
   fc = new Enumerator(f.SubFolders);
   s = "";
   for (; !fc.atEnd(); fc.moveNext())
   {
      s += fc.item();
      s += "<br>";
   }
   return(s);


Running on the network here, it's taking almost second just to return a list of 20 subdirectory names, which is too darn slow. Python has some methods that should do this lickety split, but we just wanted to check if anyone's found a native jscript technique before we build a wrapper.

How do I dislike JScript, let me count the ways... I'm really looking to get my teeth kicked in here! ;)


I concur with Kim on this one, stay away from FSO, Python and Perl's implementation of directory listing are really fast.

The two snippets below return only the directories contained in the 'dirname' location. One is in Python and the second is Kim's perl version tweaked.

Python:
import dircache
import os.path

dirname = 'C:\\'
for i in dircache.listdir(dirname):
	if os.path.isdir(os.path.join(dirname, i)):
		print i


Perl: $dirname = "C:\\";

opendir(DH, $dirname);
while($s = readdir(DH)) {
	if (-d $dirname.'/'.$s) {
		print "$s\n";
	}
}

--
Patrick Boucher
TD - Coder - Resident geek
Buzz Image Group
Tel 514.848.0579
Fax 514.848.6371

www.buzzimage.com
www.xsi-blog.com
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.