I keep getting myself in knots when I am manipulation paths and file names, because I don't have a common naming system that I use.
I need to come up with a naming standard and stick to it, and I would like to be clear and consistent with others, so I am opening up to learn the canonical answers.
Consider this toy problem: (Windows example, but hopefully answer should be platform independent)
You have been given the full name of a folder: C:\users\OddThinking\Documents\My Source. You want to walk the folders underneath, and compile all the .src to .obj.
At some point you are looking at the following string.
C:\users\OddThinking\Documents\My Source\Widget\foo.src
So, what identifier names would you use for the parts?
A) foo
B) foo.src
C) src
D) .src
E) C:\users\OddThinking\Documents\My Source\ - i.e. the top of the tree.
F) Widget\foo.src - i.e. the path from the top of the tree to the leaf.
G) Widget - i.e. one node of the tree.
H) C:\users\OddThinking\Documents\My Source\Widget\ - i.e. the name of the folder
I) C:\users\OddThinking\Documents\My Source\Widget\foo.src
Let me give some answers, to get you started.
A) base name?
B) file name? Or is it 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 in in when required? What if there is no dot on a particular file?
H) path name? Or wait, is it just the path?
I) filename. Wait, that is what I called C. Path. Wait, that is what I called H. Maybe H should be the folder name. Isn't "folder" a Windows-specific term, though?