20
1
I got a function that checks whether the passed in file name is .
or ..
. But I don't know how to name it properly. Something like IsCurrentOrParentDirectory()
is ambiguous, since the function takes a file name and not a full path. (Intuitively a fellow programmer would expect passing /usr/
while I'm in /usr/
would return true
, while this is actually not the case.)
Is there a technical term for these directory entries? If there is one, what is it?
1. and .. are NOT filenames at all, but folders. Why don't you just check if the input is a valid file (type according to stat() is IF_REG) ? P.S. This is probably more suited to StackOverflow – Tonny – 2014-07-23T09:52:24.357
7@Tonny
.
and..
are file names according to the POSIX standard. See my quote below. I'd say it's fine here as it's about general computing concepts. – slhck – 2014-07-23T12:00:54.747I have to admit that my wording was ambiguous again. The function takes a single file or directory name (
foo.bar
,foo
, ...) but not a path (foo/bar
,/foo/
, ...). But since directories, links, etc are files too, I will leave it like that. – Max Truxa – 2014-07-23T17:53:37.293@slhck POSIX calls it a file, but does that for ANY file-system object. File in POSIX terminology should usually be read as an abbreviation of "file system object". In early Unix and it's derivates all FSO's where indeed really files, but that is not true for some modern implementations and certainly not for non-Unix, but POSIX compliant Operating Systems (Windows NT as most obvious example). -- I probably should have written "is a regular file" instead of "valid file" in my comment, but the comment of Max Truxa makes it a moot point anyway. – Tonny – 2014-07-23T21:56:00.863