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

前端 未结 7 1883
心在旅途
心在旅途 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:20

    limits.h

    /*
     * File system limits
     *
     * NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
     *       required for the NUL. TODO: Test?
     * NOTE: PATH_MAX is the POSIX equivalent for Microsoft's MAX_PATH; the two
     *       are semantically identical, with a limit of 259 characters for the
     *       path name, plus one for a terminating NUL, for a total of 260.
     */
    #define PATH_MAX    260
    

    minwindef.h

    #define MAX_PATH 260
    

提交回复
热议问题