Findfile in large directories [message #50632] |
Fri, 06 October 2006 07:14  |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
Dear All,
In a widget application I'm making, I have "next file", "previous
file" buttons which do the following:
...
path = findfile(list.path+'*'+list.Format)
nfiles = n_elements(path)
path = SortListFiles(path,list.sortmethod,list.sortseparator)
ind = where(path eq list.path+list.file,count)
...
<take next or previous file (if any) and read/display it>
...
The current loaded file is "list.path+list.file". SortListFiles sorts
the files (in general not just string sort).
However, in directories with up to 1000 or more files (usually also on
an SMB mounted drive), this is rather slow (findfile takes most time).
Any ideas how to make this faster?
|
|
|
Re: Findfile in large directories [message #50683 is a reply to message #50632] |
Fri, 13 October 2006 04:38  |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
On 13 Oct 2006 03:25:15 -0700, "Maarten" <maarten.sneep@knmi.nl>
wrote:
> Well, things will be slow on and SMB mounted drive, not much you can do
> for that. How long does it take Windows Explorer to list all the files?
> And does it get notified of changes quickly and reliably?
It takes explorer +/- as long as findfile. And yes, it gets notified,
but with delays.
> Using a cache to keep a list of the files is an option, but may be hard
> if the directory contents change quickly. You may want to use
> search_file with an approriate wildcard pattern to limit the list you
> ask for to files that are likely to be next to the current file. This
> pattern will depend on the file naming convention you have for this
> directory (and please don't tell me that there is no convention for a
> directory with 1000+ files).
Appart from filtering on extention, there is no other naming
convention. The files can have different origins (apps) which you
don't know on beforehand.
> Pre-structuring your data by educating your users to use subdirectories
> and thereby limiting the number of files in a single directory might
> also help.
True. This might just be the only thing that can be done.
|
|
|
Re: Findfile in large directories [message #50684 is a reply to message #50632] |
Fri, 13 October 2006 03:25  |
Maarten[1]
Messages: 176 Registered: November 2005
|
Senior Member |
|
|
Wox wrote:
> In a widget application I'm making, I have "next file", "previous
> file" buttons which do the following:
[snip]
> The current loaded file is "list.path+list.file". SortListFiles sorts
> the files (in general not just string sort).
>
> However, in directories with up to 1000 or more files (usually also on
> an SMB mounted drive), this is rather slow (findfile takes most time).
Well, things will be slow on and SMB mounted drive, not much you can do
for that. How long does it take Windows Explorer to list all the files?
And does it get notified of changes quickly and reliably?
Using a cache to keep a list of the files is an option, but may be hard
if the directory contents change quickly. You may want to use
search_file with an approriate wildcard pattern to limit the list you
ask for to files that are likely to be next to the current file. This
pattern will depend on the file naming convention you have for this
directory (and please don't tell me that there is no convention for a
directory with 1000+ files).
Pre-structuring your data by educating your users to use subdirectories
and thereby limiting the number of files in a single directory might
also help.
Maarten
|
|
|