If I wanted to create a string which is guaranteed not to represent a filename, I could put one of the following characters in it on Windows:
\\ / : * ? | &l
An empty string is the only truly invalid path name on Linux, which may work for you if you need only one invalid name. You could also use a string like "///foo
", which would not be a canonical path name, although it could refer to a file ("/foo
"). Another possibility would be something like "/dev/null/foo
", since /dev/null
has a POSIX-defined non-directory meaning. If you only need strings that could not refer to a regular file you could use "/
" or ".
", since those are always directories.