Forbids something in Posix to have an empty string as a file name?
My experience is that trying to do anything with an empty string filename results file not found (ENOENT
), including a ls -ld ''
, touch ''
or mkdir ''
. But I could try only ext4.
While it looks quite logical to me, does it something in the Posix what would forbid that?
The 3.170 point of the Unix spec states that a filename cannot be empty:
A sequence of bytes consisting of 1 to {NAME_MAX} bytes used to name a
file. The bytes composing the name shall not contain the <NUL> or
<slash> characters.
So trying to operate on an empty filename will give an error. I would suggest testing if string is empty before trying to operate on it.