分类:
2010-12-13 11:02:57
诸如EXT3文件系统的实现并不对文件路径的长度做限制。
即便NTFS,限制也相对宽松很多。
但是,操作系统在设计时却加了些限制:
“The on-disk structures have no inherent limit. Particular drivers and may impose limits of their own, however. MS-DOS does not support full pathnames longer than 260 bytes for FAT12 and FAT16. Windows NT does not support full pathnames longer than 32,767 bytes for NTFS. Linux has a pathname limit of 4,096.”
Linux的路径长度限制为4096字节,文件名长路限制为255字节。
In linux-2.6.11/include/linux/limits.h
#define NAME_MAX 255 /* # chars in a file name */
#define PATH_MAX 4096 /* # chars in a path name including nul */(估计这里指的char字符,不是unicode字符。该点需要验证)
MSDN上也写到Windows API对文件路径的限制为260个字符(应该是Unicode字符,即中文占一个字节)。