[jcifs] Grabbing a directory and all of its subdirectories
Chris Moesel
cmoesel at mitre.org
Thu Feb 24 21:10:56 GMT 2005
Thanks Mike,
I guess my on-the-fly compilation checking isn't working in my email
client today. Funny, my email client didn't give me a stacktrace when I
tried sending the code either. I thought Mozilla Thunderbird did
*everything*. ;)
-Chris
Scovetta, Michael V wrote:
>Chris,
>
>I'd only suggest changing
> results.addAll(getFilesFromPath(file.getPath()));
>to
> results.addAll(getFilesFromDir(file.getPath()));
>so it compiles ;)
>
>
>Mike
>
>Michael Scovetta
>Computer Associates
>Senior Application Developer
>
>
>-----Original Message-----
>From: jcifs-bounces+michael.scovetta=ca.com at lists.samba.org
>[mailto:jcifs-bounces+michael.scovetta=ca.com at lists.samba.org] On Behalf
>Of Chris Moesel
>Sent: Thursday, February 24, 2005 4:01 PM
>To: jcifs at lists.samba.org
>Subject: [jcifs] Grabbing a directory and all of its subdirectories
>
>If you read my previous email, you saw that I have a need for grabbing
>the entire contents of a directory tree using the SMB protocol. You
>also saw that it takes me over 40 seconds to traverse 5400 files in 600
>subdirectories of the tree (NOTE, I don't need the actual contents of
>each file, only the information for creating a listing-- name, date,
>size, etc).
>
>Is there a best practice for doing this recursive retrieval? My current
>
>algorithm is a pretty simple recursion, but I was wondering if there was
>
>some switch in JCIFS for turning on recursive retrieval, or some API I
>was unaware of.
>
>Here's a simplified version of what I'm currently doing is:
>
>List getFilesFromDir(String path) {
> SmbFile baseDir = new SmbFile(path);
> SmbFile[] files = baseDir.listFiles();
> List results = new ArrayList();
>
> for (int i = 0; i < files.length; i++) {
> SmbFile file = files[i];
> if (file.isDirectory()) {
> results.addAll(getFilesFromPath(file.getPath()));
> } else {
> results.add(file);
> }
> }
>}
>
>Any ideas for improving performance? By the way, using log statements,
>I've been able to determine that of the 42 seconds it takes to make this
>
>call on my big directory, only 2 seconds is in my code and the remaining
>
>40 seconds is in the baseDir.listFiles() method.
>
>Also, in case you're wondering, the Microsoft server I'm querying is
>about 30 miles away-- when I run the code from the campus where the
>server resides, the 42 seconds drops down to about 24 seconds (using
>version 1.1.8 in both cases-- it is less with 1.1.3).
>
>Thanks,
>Chris
>
>
>
>
>
>
>
More information about the jcifs
mailing list