Is the 255 char limit for filenames on Windows and Unix the whole path, or part of path?

filesystems, unix, windows

Solution

In addition to the answers above, you also have to account for the filesystem being used (ext2, etc.). There's no standard answer for Unix. Linux is generally 255 per component and either 4096 for the full path, or unlimited for the path. Other Unix variants use different limits. OSX with HFS+ is 255 filename and either 1024 or unlimited path (I can't find a definitive answer). Unless you're positive you only have to worry about Linux, you'll probably want to keep the overall path low just to be sure. It's not a bad idea to limit the entire path to 255 if possible. You may also need to consider that filesystems can be network-mounted, and NFS, SMB, etc. have their own limits.

The short answer for Unix is that there is no short answer nor is there a standard, and both the operating system and the underlying filesystem impose restrictions.

Problem

Is the 255 char limit for filenames on Windows NTFS and Unix the whole path, or part of path ? i.e given c:\part1\part2 have just part1 and part2 got to be less than 255 or is it C:\ + part1 + part2 And whats the rules on Unix ?

Original source

Related problems