Question

  1. What are the origins and reasons for the terms, dirname and basename, referring to the path with the trailing component removed, and the trailing component respectively?
  2. Is the terminology standardized, and where?
  3. Are there alternative or equivalent conventions in use to refer to the splitting of a path in this way?

Update0

In particular, alternatives used on major operating systems or libraries are of interest.

Was it helpful?

Solution

The terms dirname and basename seem quite straightforward, i.e. "directory name" and "base name within the directory", so I don't think there is any specific reason for these names.

I'm not sure what you mean by "Is the terminology standardized". The calls are part of the POSIX standard (dirname, basename) but they've also been borrowed by many high-level languages like PHP (dirname, basename), Perl and Python.

Other equivalents:

On Windows, the shell API provides the PathRemoveFileSpec and PathStripPath functions, which are similar to dirname and basename.

In Java, the File class provides getParent and getName which do the same thing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top