Recursive directory search
-
Hereinafter, / should be backslash. I am working on a recursive directory search function. It uses FindFirstFile, FindNextFile, WIN32_FIND_DATA info; , etc. It seems to work. If while working on directory X it comes across a subdirectory X/Y, it calls itself recursively to search the contents of directory X/Y (unless the directory's name starts with a fullstop). OK so far. But, if the function recurses (say) 6 deep in a deep nest of directories, then the computer will have to keep tract of 6 FindFirstFile, FindNextFile, WIN32_FIND_DATA info; directory scan processes at once. Can I trust the computer to keep tract of all that lot at once and not trip over itself?
-
Hereinafter, / should be backslash. I am working on a recursive directory search function. It uses FindFirstFile, FindNextFile, WIN32_FIND_DATA info; , etc. It seems to work. If while working on directory X it comes across a subdirectory X/Y, it calls itself recursively to search the contents of directory X/Y (unless the directory's name starts with a fullstop). OK so far. But, if the function recurses (say) 6 deep in a deep nest of directories, then the computer will have to keep tract of 6 FindFirstFile, FindNextFile, WIN32_FIND_DATA info; directory scan processes at once. Can I trust the computer to keep tract of all that lot at once and not trip over itself?
-
When you say "the computer", do you mean your application, or the windows system? If the former then only you can say; if the latter then: yes.
If the function recurses (say) 6 deep in a deep nest of directories, then each recursion level would have to keep track of a level of the directory tree, by a FindFirstFile, FindNextFile, WIN32_FIND_DATA info; directory scan process, all 6 at the same time. Can one application be trusted to run these 6 FindFirstFile, FindNextFile , WIN32_FIND_DATA info; directory-scans at once?
-
If the function recurses (say) 6 deep in a deep nest of directories, then each recursion level would have to keep track of a level of the directory tree, by a FindFirstFile, FindNextFile, WIN32_FIND_DATA info; directory scan process, all 6 at the same time. Can one application be trusted to run these 6 FindFirstFile, FindNextFile , WIN32_FIND_DATA info; directory-scans at once?
Anthony Appleyard wrote:
Can one application be trusted to run these 6 FindFirstFile, FindNextFile , WIN32_FIND_DATA info; directory-scans at once?
Well it isn't doing them all at once, it is doing them one at a time. If you are concerned about testing your application it is easy enough to create a structure to run your application on. But be aware of the limitations imposed by the MAX_PATH constant as described at FindFirstFile function (Windows)[^].
-
Hereinafter, / should be backslash. I am working on a recursive directory search function. It uses FindFirstFile, FindNextFile, WIN32_FIND_DATA info; , etc. It seems to work. If while working on directory X it comes across a subdirectory X/Y, it calls itself recursively to search the contents of directory X/Y (unless the directory's name starts with a fullstop). OK so far. But, if the function recurses (say) 6 deep in a deep nest of directories, then the computer will have to keep tract of 6 FindFirstFile, FindNextFile, WIN32_FIND_DATA info; directory scan processes at once. Can I trust the computer to keep tract of all that lot at once and not trip over itself?
When the function is called again, all of the context information is pushed onto the stack and the new function call starts. When the function unwinds, the most recent context information is popped from the stack and the function picks up where it left off. This is all handled automatically by the system.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles