How can I determine the maximum filename length on a linux box?
Preferred in PHP programming language.
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
there's no need to programatically determine it. it's 255 bytes.
edit: you can have longer filenames on a very few file systems (reiser, i believe), but if you stick to 255 your app will be usable on any linux installation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With