简体   繁体   English

子文件夹允许的最大深度是多少?

[英]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" 起初我想问“Windows操作系统允许的最大子文件夹是什么”

But then I figured maybe my web hosting provider isn't on windows but on linux or something else. 但后来我想,也许我的网络托管服务提供商不是在Windows上,而是在Linux或其他东西上。 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?) (说Linux,Mac或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.) (为什么会这样?因为我希望每个用户都有自己的文件夹,以便轻松访问他们的图像。这样可以吗?或者这是不好的做法?编程还是新手。)

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 . 大多数文件系统(在Linux上)对其inode数量有固定限制。

Some file systems behave poorly with directories containing ten thousand entries (eg because the search is linear not dichotomic). 某些文件系统在包含一万个条目的目录中表现不佳(例如,因为搜索是线性的而不是二分法)。 And you have hard time to deal with them (eg even ls * gives too long output). 你很难处理它们(例如,即使ls *输出太长)。 Hence, it could be wise to have /somepath/a/0001 ... /somepath/z/9999 instead of /somepath/a0001 ... /somepath/z9999 因此,有/somepath/a/0001 ... /somepath/z/9999而不是/somepath/a0001 ... /somepath/z9999可能是明智的

If you have many thousands of users each with his directory, you might want to eg group the users by their initials, eg 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... 如果您的目录中有成千上万的用户,您可能希望例如按用户的首字母对用户进行分组,例如有/some/path/A/userAaron/images/foobar/some/path/B/userBasile/images/barfoo等所以/some/path/A/只有几百个子目录等...

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. 某些Web应用程序将小数据块存储在SQL数据库的各个行中,并使用文件(可能生成其名称)用于较大的数据块,并将文件路径存储在数据库中。 Having millions of files with only a few dozen bytes in most is probably not efficient. 拥有数百万个文件,大多数只有几十个字节可能效率不高。

Some sysadmins are also using quotas on filesystems. 一些系统管理员也在文件系统上使用配额

In Windows, there is a limit for 260 characters in any path. 在Windows中,任何路径中都有260个字符的限制。 This includes filenames, so a file cannot have more characters than 260-directory path length . 这包括文件名,因此文件不能包含超过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. 这意味着您可以拥有相当多的子目录,但随着您的深入,最大文件名会变短。

Something else that's very important is performance. 其他一些非常重要的是性能。 With Windows if you start to get over 5k files it starts to get slow, 10k it is crawling and 50k becomes totally unusable! 使用Windows,如果你开始获得超过5k文件,它开始变慢,10k它爬行,50k变得完全无法使用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM