What is the naming standard for path components?

I keep getting myself in knots when I am manipulating paths and file names because I don’t follow a naming standard for path components.

Consider the following toy problem (Windows example, but hopefully the answer should be platform independent). You have been given the path of a folder:

C:\users\OddThinking\Documents\My Source\

You want to walk the folders underneath and compile all the .src files to .obj files.

At some point you are looking at the following path:

C:\users\OddThinking\Documents\My Source\Widget\foo.src

How would you name the following path components?

A. foo
B. foo.src
C. src
D. .src
E. C:\users\OddThinking\Documents\My Source\ (i.e. the absolute path of the root)
F. Widget\foo.src (i.e. the relative path of the file)
G. Widget\
H. C:\users\OddThinking\Documents\My Source\Widget\
I. C:\users\OddThinking\Documents\My Source\Widget\foo.src

Here is my attempt:

A. Base name? Basename?

B. File name? Filename? The difference is important when choosing identifier names, and I am never consistent here.

C. Extension?

D. Extension? Wait, that is what I called C. Should I avoid storing the dot, and just put it in when required? What if there is no dot on a particular file?

E. ?

F. ?

G. Folder? But isn’t this a Windows-specific term?

H. Path name? Pathname? Path?

I. File name? Wait, that is what I called C. Path name? Wait, that is what I called H.

8 Answers
8

Leave a Comment