路径组件的命名标准是什么? [英] 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.
请考虑以下玩具问题(以Windows为例,但希望答案应该与平台无关).已为您提供了文件夹的路径:
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\
您要遍历下面的文件夹,并将所有.src文件编译为.obj文件.
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
您如何命名以下路径组件?
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
这是我的尝试:
A.基本名称?基本名称?
A. Base name? Basename?
B.文档名称?文档名称?选择标识符名称时,区别很重要,在此我永远不会保持一致.
B. File name? Filename? The difference is important when choosing identifier names, and I am never consistent here.
C.扩展吗?
D.扩大?等等,这就是我所说的C.我应该避免存储点,而是在需要时才将其放入吗?如果特定文件上没有点怎么办?
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.文件夹?但这不是Windows专有的术语吗?
G. Folder? But isn’t this a Windows-specific term?
H.路径名?路径名?路径?
H. Path name? Pathname? Path?
I.文档名称?等等,这就是我所说的C.路径名?等等,这就是我所说的H.
I. File name? Wait, that is what I called C. Path name? Wait, that is what I called H.
推荐答案
我认为您对标准"命名约定的搜索是徒劳的.这是我基于现有知名程序的建议:
I think your search for a "standard" naming convention will be in vain. Here are my proposals, based on existing, well-known programs:
A)C:\ users \ OddThinking \ Documents \ My Source \ Widget \ foo .src
A) C:\users\OddThinking\Documents\My Source\Widget\foo.src
Vim称之为文件根(:help文件名修饰符)
Vim calls it file root (:help filename-modifiers)
B)C:\ users \ OddThinking \ Documents \ My Source \ Widget \ foo.src
B) C:\users\OddThinking\Documents\My Source\Widget\foo.src
C)C:\ users \ OddThinking \ Documents \ My Source \ Widget \ foo. src (不带点)
C) C:\users\OddThinking\Documents\My Source\Widget\foo.src (without dot)
D)C:\ users \ OddThinking \ Documents \ My Source \ Widget \ foo .src (带点)
D) C:\users\OddThinking\Documents\My Source\Widget\foo.src (with dot)
也是文件扩展名.只需存储不带点的文件,如果文件上没有点,则文件没有扩展名
also file extension. Simply store without the dot, if there is no dot on a file, it has no extension
E) C:\ users \ OddThinking \ Documents \ My Source \ Widget \ foo.src
E) C:\users\OddThinking\Documents\My Source\Widget\foo.src
树顶
没有约定,git将其称为基本目录
top of the tree
No convention, git calls it base directory
F)C:\ users \ OddThinking \ Documents \ My Source \ Widget \ foo.src
F) C:\users\OddThinking\Documents\My Source\Widget\foo.src
从树顶到叶子的路径
相对路径
path from top of the tree to the leaf
relative path
G)C:\ users \ OddThinking \ Documents \ My Source \ 小部件 \ foo.src
G) C:\users\OddThinking\Documents\My Source\Widget\foo.src
树的一个节点
没有约定,也许是一个简单的目录
one node of the tree
no convention, maybe a simple directory
H) C:\ users \ OddThinking \ Documents \ My Source \ Widget \ foo.src
H) C:\users\OddThinking\Documents\My Source\Widget\foo.src
I) C:\ users \ OddThinking \ Documents \ My Source \ Widget \ foo.src
这篇关于路径组件的命名标准是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!