Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the maximum allowed depth of sub-folders?

At first I wanted to ask "What is the maximum allowed sub-folder for a windows OS"

But then I figured maybe my web hosting provider isn't on windows but on linux or something else. So I'm asking what are the possible maximum allowed sub-folder for all major OS that a Web Hosting Provider would usually use. (Would it be safe to say Linux, Mac, or Windows?)

Then again, based on your experiences, do web hosting sites create a limit to the number of subfolders we can make?

(Why this? Because I want each user to have their very own folder for easy access to their images. Would that be ok? Or is it bad practice? Still new to programming.)

like image 883
Jo E. Avatar asked Mar 20 '13 06:03

Jo E.


2 Answers

The limit is not on the depth of the nested subdirectories (you could have dozens of them, even more), but on the file systems and its quotas.

Also having very long file paths is inconvenient (and could be slightly inefficient). Programmatically, a file path of several hundreds or even thousands of characters is possible; but the human brain is not able to remember such long file paths.

Most file systems (on Linux) have a fixed limit to their number of inodes.

Some file systems behave poorly with directories containing ten thousand entries (e.g. because the search is linear not dichotomic). And you have hard time to deal with them (e.g. even ls * gives too long output). Hence, it could be wise to have /somepath/a/0001 ... /somepath/z/9999 instead of /somepath/a0001 ... /somepath/z9999

If you have many thousands of users each with his directory, you might want to e.g. group the users by their initials, e.g. have /some/path/A/userAaron/images/foobar and /some/path/B/userBasile/images/barfoo etc. So /some/path/A/ would have only hundreds of subdirectories, etc...

A convenient rule of thumb might be: avoid having more than a few hundreds entries -either subdirectories or files- in each directory.

Some web applications store small data chunk in individual rows of a SQL databases and use files (whose name might be generated) for larger data chunks, storing the filepath in the database. Having millions of files with only a few dozen bytes in most is probably not efficient.

Some sysadmins are also using quotas on filesystems.

like image 111
Basile Starynkevitch Avatar answered Oct 24 '22 08:10

Basile Starynkevitch


In Windows, there is a limit for 260 characters in any path. This includes filenames, so a file cannot have more characters than 260-directory path length.

This means that you could have quite a lot of subdirectories, but as you go deeper, the maximum filename gets shorter.

like image 44
carlpett Avatar answered Oct 24 '22 09:10

carlpett