I suggest to use the following approach in the naming:
filename- file name:readme.txtdirname- directory name:mydirfilepath- file name, including any path to it:path/to/readme.txtdirpath- directory name, including any path to it:path/to/mydir
As for the words file and dir themselves, I'd recommend not using them for paths at all, because:
fileis a good name for storing file objects.dircan be used for DirEntry objects of readdir/opendir etc.
However, since the latter usage is not very common, to save typing dir can also be used as an alias for the a dirname based variable in a local context.
Suppose we have a baz project directory with a readme.txt file.
Then we could define the following variables:
| camelCase | snake_case | path/to/baz/readme.txt |
|---|---|---|
| readmeFilename | readme_filename | readme.txt |
| readmeFilepath | readme_filepath | path/to/baz/readme.txt |
| readmeDirname | readme_dirname | baz/ |
| readmeDirpath | readme_dirpath | path/to/baz/ |
| projectDirname | project_dirname | baz/ |
| projectDirpath | project_dirpath | path/to/baz/ |
NOTE: The slash character after directories above is optional.