4 ms·
Ask HN: How many levels deep is the deepest directory on the average PC?
Files are typically arranged in hierarchical structures. An example might be:
Home -> User -> programs -> Hello_World -> bin -> run.exe
Home -> User -> programs -> Hello_World -> readme.txt
When we think about all the libraries and nested files required to run the average computer, my gut feeling is that one my descend deep down the rabbit hole to get down to the most core file of computing.
Is the total number of hierarchies between the top level and the bottom level an easily measurable thing? Does this number have significant impact on efficiency or on some other parameter important to the computers function? Does this number differ significantly from architecture to architecture (MacOS to Windows for example)?
- jeffmould 10y agoIt's been a while since I last checked, but if I remember correctly, Windows has a 255 character path limit.
- ReedJessen 10y agoAh, great point. I didn't think of this constraint. So the maximum number of hierarchies is something around 127? eg a/a/a/a/a/a/a/a/a
- new_hackers 10y agoyes, AFAIK this is still true today
- jf 10y agoFor the curious, this page contains a helpful comparison maximum pathname lengths of various filesystems: https://en.wikipedia.org/wiki/Comparison_of_file_systems https://en.wikipedia.org/wiki/Comparison_of_file_systems
- viraptor 10y ago> Is the total number of hierarchies between the top level and the bottom level an easily measurable thing? Sure. Just check all the files on your disk. > Does this number have significant impact on efficiency or on some other parameter important to the computers function? Not once the file is accessed and all the relevant structures are cached. Actually on some filesystems it's beneficial to split directories with lots of files (think millions) into deeper hierarchies. You can sometimes see this bubbling up to the visible layer on some file hosting sites. You get a url that looks like example.com/file/so/me/somehash (first characters of the hash are used for the hierarchy split)
- jf 10y agoHere is how I'm trying to measure this on my system: (for d in `find / -type d | sed 's/[^\/]//g'`; do echo $d | wc -c; done) | sort -n Edit: It looks like the deepest directory on my (Mac OS X) system is 27 directories deep.
- ReedJessen 10y agoSo cool. Thanks.