Search code examples
phplinuxpathfilenamesname-length

Programmatically determine maximum filename length


How can I determine the maximum filename length on a linux box?

Preferred in PHP programming language.


Solution

  • You want pathconf or fpathconf, which are not exposed (yet) in PHP. (When they are, they'll probably be posix_pathconf.)

    You may also shell out to getconf, a command-line utility interface to the same functionality. Try this on your system:

    $ getconf NAME_MAX /tmp

    $ getconf PATH_MAX /tmp