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

前端 未结 7 1892
心在旅途
心在旅途 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条回答
  •  天涯浪人
    2020-12-01 01:06

    FILENAME_MAX is part of the ISO C standard, it works on UNIX and Windows. However, the GNU C library documentation contains the following warnings:

    "Unlike PATH_MAX, this macro is defined even if there is no actual limit imposed. In such a case, its value is typically a very large number. This is always the case on the GNU system.

    Usage Note: Don't use FILENAME_MAX as the size of an array in which to store a file name! You can't possibly make an array that big! Use dynamic allocation."

提交回复
热议问题