lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Interestingly, fopen() seems to be able to deal with very long path
> names on both Linux and Windows, even though, per the standard, it
> should only be called with filenames not longer than FILENAME_MAX,
> which is a relatively small constant on these systems. The C standard
> uses peculiarly ambiguous language when talking about FILENAME_MAX, so
> it is debatable whether undefined behavior could ever ensue.

The C standard is not clear, but Posix explicitly lists ENAMETOOLONG
as a possible error for fopen:

    https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html

    "[ENAMETOOLONG] The length of a pathname exceeds {PATH_MAX}, or
    pathname resolution of a symbolic link produced an intermediate
    result with a length that exceeds PATH_MAX."

-- Roberto