I had some free time today so I thought of writing some code to mimick CFDIRECTORY functionality using Java objects. As always, the idea of being able to call Java from within CF has always got me excited. I have seen a lot of code out there that uses JAVA to list files in a directory, however, I havent seen any code that returns all the attributes that CFDIRECTORY does. So this is what I decided to do today.
Here is the function I wrote Directory listing :-
Here is how I used it :-
<cfset args = structnew() /> <cfset args.pathToparse = "F:\install"> <cfset args.recurse = "true"> <cfset t = getTickCount() /> <cftimer label="timing" type="debug"> <cfset myquery2 = #DirectoryListing(argumentCollection=args)#> </cftimer>
On my machine this code takes 42ms to run. I think thats on the higher side as compared to the CFDIRECTORY tag in CF8 which takes only under 20ms for the same code. The only difference is that my function returns 2 new attributes, one of them is if the file is hidden or not and the second one is the path to the file.
This is a bit surprising for me as I thought the Java version would be faster but I think CF8 has made some major improvements in its file handling operations.
Any comments ?