Is there an equivalent to WinAPI's MAX_PATH under linux/unix?

前端 未结 7 1889
心在旅途
心在旅途 2020-12-01 00:40

If I want to allocate a char array (in C) that is guaranteed to be large enough to hold any valid absolute path+filename, how big does it need to be.

On Win32, ther

7条回答
  •  旧时难觅i
    2020-12-01 01:15

    Well, on Linux at least, there is:

    • PATH_MAX (defined in limits.h)

    • FILENAME_MAX (defined in stdio.h)

    both of these are set to 4096 on my system (x86 Linux).

    Update: : Some info from the glibc manual on this

    Each of the following macros is defined in limits.h only if the system has a fixed, uniform limit for the parameter in question. If the system allows different file systems or files to have different limits, then the macro is undefined; use pathconf or fpathconf to find out the limit that applies to a particular file

提交回复
热议问题