Re: Findfile in large directories [message #50595] |
Mon, 09 October 2006 06:00  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Wox writes:
> FILE_SEARCH makes it even slower.
Well, now it's finding all the files. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
|
Re: Findfile in large directories [message #50624 is a reply to message #50598] |
Fri, 06 October 2006 11:26   |
George N. White III
Messages: 56 Registered: September 2000
|
Member |
|
|
On Fri, 6 Oct 2006, Wox wrote:
> 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?
If the contents of the directories are not updated too often you can
generate a cached list of the files. This is essentially what is done by
most TeX (math typesetting) implementations, using the unix "ls -R"
command to cache the names for a directory tree.
--
George N. White III <aa056@chebucto.ns.ca>
|
|
|
Re: Findfile in large directories [message #50631 is a reply to message #50624] |
Fri, 06 October 2006 07:22   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Wox writes:
> 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?
FINDFILE is obsolete. Have you tried FILE_SEARCH?
No idea if it would be faster or not. I'd have guessed
the sorting would be the bottleneck here.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: Findfile in large directories [message #50686 is a reply to message #50596] |
Fri, 13 October 2006 01:03  |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
Unfortunatly, the directory content is changing all the time and I
don't know how many files will be dumped at any given moment, so
keeping track of the list myself will be difficult (offcourse having
the "dumping" applications notify me when and what they are dumping
might be an option, I will look into that.)
Anyway, thanks to all for your replies.
On 9 Oct 2006 03:35:45 -0700, "greg michael" <greg.michael@gmail.com>
wrote:
>
> Keep the paths in an array - don't read them every time. Sometimes it
> takes a long time to get a directory listing when there are so many. If
> you're adding files to the list, you might want to keep track of them
> yourself.
>
> regards,
> Greg
>
>
>
>
> Wox wrote:
>> On Fri, 6 Oct 2006 08:22:43 -0600, David Fanning <davidf@dfanning.com>
>> wrote:
>>>
>>> FINDFILE is obsolete. Have you tried FILE_SEARCH?
>>> No idea if it would be faster or not. I'd have guessed
>>> the sorting would be the bottleneck here.
>>>
>>> Cheers,
>>>
>>> David
>>
>> FILE_SEARCH makes it even slower.
|
|
|