Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Recursive directory search

Recursive directory search

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anthony Appleyard
    wrote on last edited by
    #1

    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?

    L D 2 Replies Last reply
    0
    • A Anthony Appleyard

      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?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • L Lost User

        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.

        A Offline
        A Offline
        Anthony Appleyard
        wrote on last edited by
        #3

        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?

        L 1 Reply Last reply
        0
        • A Anthony Appleyard

          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?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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)[^].

          1 Reply Last reply
          0
          • A Anthony Appleyard

            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?

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups