Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically determine maximum filename length

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

Preferred in PHP programming language.

like image 679
prinzdezibel Avatar asked Jul 24 '09 15:07

prinzdezibel


2 Answers

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

like image 136
pilcrow Avatar answered Oct 05 '22 01:10

pilcrow


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.

like image 36
glomad Avatar answered Oct 05 '22 03:10

glomad