当我操作路径和文件名时,我一直处于打结状态,因为我没有使用的通用命名系统.
我需要提出一个命名标准并坚持下去,我希望与其他人保持清晰和一致,所以我开放学习规范的答案.
考虑这个玩具问题:( Windows示例,但希望答案应该是平台无关的)
您已获得文件夹的全名:C:\ users\OddThinking\Documents\My Source.您想要遍历下面的文件夹,并将所有.src编译为.obj.
在某些时候,您正在查看以下字符串.
C:\users\OddThinking\Documents\My Source\Widget\foo.src
Run Code Online (Sandbox Code Playgroud)
那么,您将使用哪些标识符名称?
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
Run Code Online (Sandbox Code Playgroud)
让我给出一些答案,让你开始吧.
A)基地名称?
B)文件名?还是文件名?选择标识符名称时,差异很重要,我在这里永远不会保持一致.
C)扩展
D)扩展.等等,这就是我所说的C.我应该避免存储点,只需要在需要时插入?如果特定文件上没有点怎么办?
H)路径名称?或等等,这只是路径吗?
I)文件名.等等,这就是我所说的C. Path.等等,这就是我所说的H.也许H应该是文件夹名称.不是"文件夹"是特定于Windows的术语吗?