Faster way than findfirst to count files in a directory?
Well, as my title says, is there a faster way to count files in a directory else than going through files with libc's findfirst or Win32's FindFirstFile ?
Not really, but it shouldn't be too slow using FindFirstFile. Are you counting thousands of files? If not, and you're having speed problems, there may be some other problem in your code.
I'm not an authority, but like low-level fiddling and have searched docs + libraries for such things.
Afraid not :/ The Find*File interface being the only means we have is a bit strange, but that's the way it is.
Extrarius: my game file system currently scans all files in its mount points at init. Surprisingly, only enumerating them can take ~300 ms for several thousand of them; it gets a bit better on subsequent runs because Windows is apparently caching directory records. Now this can be solved by only scanning directories on-demand, but the point is that this kind of thing can be unpleasantly slow.
Out of curiousity, what is the intended application?
Afraid not :/ The Find*File interface being the only means we have is a bit strange, but that's the way it is.
Extrarius: my game file system currently scans all files in its mount points at init. Surprisingly, only enumerating them can take ~300 ms for several thousand of them; it gets a bit better on subsequent runs because Windows is apparently caching directory records. Now this can be solved by only scanning directories on-demand, but the point is that this kind of thing can be unpleasantly slow.
Out of curiousity, what is the intended application?
Thanks for the replies.
As for the purpose, well, I'm programming a little Virtual File System for my future games, or the re-fitting of my current Tetris game. It'll allow using either direct files or files-in-an-archive transparently to the game, by changing only the mount points.
The reason why I asked for a faster way is that if I try to count Windows' System32 folder, 1732 files, there is a noticeable delay, something like half a second, well, something that I can see takes more than a couple of microseconds :) So I wondered if there was a faster way to report the number of files without processing them all.
Thanks.
As for the purpose, well, I'm programming a little Virtual File System for my future games, or the re-fitting of my current Tetris game. It'll allow using either direct files or files-in-an-archive transparently to the game, by changing only the mount points.
The reason why I asked for a faster way is that if I try to count Windows' System32 folder, 1732 files, there is a noticeable delay, something like half a second, well, something that I can see takes more than a couple of microseconds :) So I wondered if there was a faster way to report the number of files without processing them all.
Thanks.
Quote:The reason why I asked for a faster way is that if I try to count Windows' System32 folder, 1732 files, there is a noticeable delay, something like half a second, well, something that I can see takes more than a couple of microseconds :) So I wondered if there was a faster way to report the number of files without processing them all.
Ah, I have the exact same problem :) Need to trawl through all DLLs there to check for OpenAL DLLs (names are unknown) and report their versions.
Are you writing the VFS for fun|education or just to have one? In the latter case, I would recommend PhysicsFS or my code (GPL; still under active development; design goals: maximum efficiency, hotloading, support for source control and mods; get in touch if interested).
I'm writing it for my personal enjoyment, to enhance my already working game and for my future projects. My VFS will be very simple, but it should prove useful.
What's your project like? Where or how could I have info on it?
[edit]
I've used everybody's friend Google (tm) and found your web page very easily. Your library seems to have quite a history and seems really nice.
Tell me, how can you build such a structured library, with documentation and all, multi-platform, etc? It really seems out of my grasp :)
[Edited by - persil on August 16, 2005 7:22:52 AM]
What's your project like? Where or how could I have info on it?
[edit]
I've used everybody's friend Google (tm) and found your web page very easily. Your library seems to have quite a history and seems really nice.
Tell me, how can you build such a structured library, with documentation and all, multi-platform, etc? It really seems out of my grasp :)
[Edited by - persil on August 16, 2005 7:22:52 AM]
Quote:I'm writing it for my personal enjoyment, to enhance my already working game and for my future projects. My VFS will be very simple, but it should prove useful.
Ah, ok :)
Quote:What's your project like? Where or how could I have info on it?
I'm working on 0 A.D., but have been using and adding to the low-level code over several previous projects. It will eventually be released, but I have no time for that at the moment (exams pending). If you send me your email address, I could give you a snapshot, though (GPL license).
Quote:I've used everybody's friend Google (tm) and found your web page very easily. Your library seems to have quite a history and seems really nice.
Tell me, how can you build such a structured library, with documentation and all, multi-platform, etc? It really seems out of my grasp :)
Thanks for the kind words :)
heh, The Mythical Man-Month says that documented code is 3x as expensive to write vs. throwaway hacks, and integrating it with other modules is another 3x on top of that. Starting to believe it.. ;)
I have been growing it over the past 3 years, and it's about ripe.
Also, one of the design principles is not to create new APIs whenever possible - I emulate POSIX functions for Win32, and thus only need to learn/write/test one set of wrappers.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement