Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Depth Listing in Directory Traversal

by hbo (Monk)
on Jul 20, 2004 at 05:35 UTC ( #375814=note: print w/replies, xml ) Need Help??


in reply to Re^2: Depth Listing in Directory Traversal
in thread Depth Listing in Directory Traversal

On Windows,"\" is the path seperator. A file name can't contain that character, so you won't encounter it unless it means a depth transition in the stack. Same goes for "/" on Unix. The tricky part with Windows would be a rooted path like "c:\\". For that you could count occurrences of "\+",although I believe that ActivePerl translates the seperators to "/" for portability with Unix.

The "width first" traversal of the directory tree doesn't matter in the code I gave. The path seperator count will be the same between peer directories, thus their difference will be zero, and we will add zero to the depth counter. This also works for transitions up the stack, since that difference will be negative.

  • Comment on Re^3: Depth Listing in Directory Traversal

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://375814]
help
Chatterbox?
choroba knows the situation. At work, unit tests run for 30 minutes, and integration and end-to-end tests take almost one hour.
[stevieb]: yeah. This is my build/test software that manipulates perlbrew/ berrybrew, and runs all unit tests of a project against all installed versions, including testing a dist against all of it's current revdeps. A lot of tests it runs for itself:)
[stevieb]: testing the test build system, essentially

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2017-03-26 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (315 votes). Check out past polls.