On 9/8/06, Mary Jo Sminkey <[EMAIL PROTECTED]> wrote: > > >I think Ben(?) blogged about it, and I managed to get one going > >for some tests, so I'll see if the code is lying around. > > > >I don't think it's really much faster than the isDirectory() looping > >though... IIRC. Man, I really need to get more organizeder. [-= > > I'd certainly be interested to see it and if it's comparable in speed. > Just seems there should be better way to do this than looping through the > entire list twice...once to get the subdirectories and again to list the > files. CFDirectory handles this by returning the type, which I can run a > Q-o-Q against, but it chokes on the large numbers of files. I've also not > tested with listFiles() yet but I'm guessing it's not nearly as fast as > list() is.
Well, I found the old code, but man it's a mess. I've put it in my googlecode repository at: http://musingrandom.googlecode.com/svn/trunk/cfmx/randomjava/ You'll only want a few lines, really. >From filestuff.cfm: targetDir = "C:\build"; // NO TRAILING SLASH!! currentDirectory = expandPath("./"); currentDirectory = replace(currentDirectory,"\","/","all"); urls[1] = createObject("java","java.net.URL ").init("file:#currentdirectory#"); GetObject = createObject("java","coldfusion.bootstrap.BootstrapClassLoader ").SystemClassLoader.newInstance(urls).loadClass("DirFilter").newInstance(); dumpvar(GetObject.doFileFilterDirectoryListing(javacast("string",targetDir))); And from the java file: File dir = new File(dirName); File[] files = dir.listFiles(); // This filter only returns directories FileFilter fileFilter = new FileFilter() { public boolean accept(File file) { return file.isDirectory(); } }; files = dir.listFiles(fileFilter); for (int i=0; i<files.length; i++) { System.out.println("[D] : " + files[i]); } I just couldn't figure out how to create a filefilter without using java... that "public boolean accept(File file)" got me. And the java class just spits text out to System.out, which isn't going to do you much good if you don't know where CF is outputting it to (that dump will probably just list the methods). I haven't re-tested this code since I was messing with it, not sure if it even still works... Sorry it's such a mess, I was really just playing around and never got it to the "share worthy" level. Hopefully it will give you an idea of how I did it though, maybe enough to do some testing... May the Force be with you, :Den ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:252650 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

