Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
. 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 Jul 23 '14 at 9:52
@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 Jul 23 '14 at 12:00
I have to admit that my wording was ambiguous again. The function takes a single file or directory name (, foo, ...) but not a path (foo/bar, /foo/, ...). But since directories, links, etc are files too, I will leave it like that. – Max Truxa Jul 23 '14 at 17:53
@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 Jul 23 '14 at 21:56

5 Answers 5

up vote 22 down vote accepted

From the POSIX standard:

The special filename dot shall refer to the directory specified by its predecessor. The special filename dot-dot shall refer to the parent directory of its predecessor directory. As a special case, in the root directory, dot-dot may refer to the root directory itself.

So, really, if you want to check whether the filename is . or .. you would have to call it IsDotOrDotDot(), or, using the POSIX terminology of pathname resolution, IsPredecessorOrParentOfPredecessor(), or maybe even PointsToPredecessorOrParentOfPrecedessor() … you get the idea. The problem is that the latter terminology only makes sense when looking at full pathnames. But nobody would understand that anyway.

Considering that . and .. are valid filenames (just interpreted differently), you should just stick to what you have, relying on the meaning rather than how they are called internally.

share|improve this answer
Is .bash_history dot or not dot? I'm not sure if that function name is more descriptive than the open the OP proposed. – Jens Erat Jul 23 '14 at 7:01
@JensErat That's irrelevant to the problem. The question was whether the filename component was . or .., and not whether it just started with a .. Of course the OP's function name is more descriptive; I was just pointing him to how it's technically referred to. – slhck Jul 23 '14 at 7:19
Sure it is, but IsDotOrDotDot() says pretty much nothing about what the function is doing at all. – Jens Erat Jul 23 '14 at 7:22
"predecessor" refers to the path element immediately before it in the path specification. If you are just looking at the names of entries in a directory, "current" or "parent" is better terminology. – Simon Richter Jul 23 '14 at 11:56
@JensErat I would use IsDotOrDotDot. Anyone knowledgeable with filesystem concepts would instantly understand it. It is debatable whether .bash_history is “dot” because no context is provided then for the meaning of “dot”, but it is definitely NOT “dot or dot dot”. – kinokijuf Jul 23 '14 at 14:46

. and .. are usually used to describe relative paths vs. absolute ones like /usr. I'd use this difference and declare the function as IsRelativeCurrentOrParentDirectory().

Be aware the dot-references may occur anywhere in the path. What about /usr/local/..?

share|improve this answer
I failed to point out that the function does only take a file name and not a full path. I updated the question accordingly. – Max Truxa Jul 23 '14 at 7:34

The POSIX Standard, which slhck♦ usefully quoted, says,

The special filename dot shall refer to ….  The special filename dot-dot shall refer to ….

(emphasis added).  So, while it’s not exactly technical, it looks like “special filename” just might be the official name.  Your users would probably understand it if you called your function any of the following: IsSpecialDirectory(), IsSpecialFilename(), or simply IsSpecialName().

Or you could go with IsStandardDirectory(), IsStandardFilename(), or IsStandardName().  This follows the Unix naming convention (standard input, standard output) for things that are established for you automatically (in this case, by mkfs and mkdir).  IsAutomatic…() or IsDefault…(), on the other hand, probably are not intuitive enough.

share|improve this answer
Actually the first name I took was IsMagicDirectory() so that's pretty close to that, but I think your wording is much more intuitive and appropriate (especially since it uses established naming conventions). Using IsSpecialFileName would even make it clear that the function does not receive a path but a single file (or directory, link, etc) name. – Max Truxa Jul 24 '14 at 6:58
Good suggestion. "Special" however would probably also include links, FIFOs, etc., right? – slhck Jul 24 '14 at 9:44
@slhck: Yes, devices (e.g., disks and ttys) are called “special files”. And, yes, the term could be loosely applied to symbolic links, FIFOs, and other exotic denizens of the file system – any type of file (i-node) other than a “regular file”. (Yes, directories fall into this bucket, too.) So IsSpecialFile() would have been a bad suggestion. But I didn’t suggest that; I suggested IsSpecialFilename(). While the names sda1, console, kmem, myfifo and urandom are suggestive, they are not reserved and are not inherently special. But . and .. are inherently special filenames. – Scott Jul 24 '14 at 16:39

The only term I know of from the *nix world is CWD for Current Working Directory. That is actually quite often used. See, for example /proc/$$/cwd which is a link to the directory you run the command from.

I don't know of any standard name for .. apart from dot-dot and as @slhck pointed out that's not a good choice.

share|improve this answer

Posix is pretty ambiguous on speaking about parent-child directory relationships. As others have said, ./.. isn't helpful while talking or communicating with other humans.

File structures can be thought about as a tree data structure. Here, generally "parent" and "child" or "daughter" are sufficient to convey meaning. You'll see data structure textbooks carry this convention

Alternatively, it seems like trees can be talked about as "up" and "down" the tree. By convention, "up" means closer to the root directory, and "down" refers to the child(ren).

I think either IsCurrentOrUp() or IsCurrentOrParent() can be argued to be good practice for naming functions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.