文档名称?路径名?基本名称?路径片段的命名标准 [英] File name? Path name? Base name? Naming standard for pieces of a path

查看:249
本文介绍了文档名称?路径名?基本名称?路径片段的命名标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我处理路径和文件名时,我总是陷入困境,因为我没有通用的命名系统.

I keep getting myself in knots when I am manipulating 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.

考虑这个玩具问题:(以Windows为例,但希望答案应该与平台无关)

Consider this toy problem: (Windows example, but hopefully answer should be platform independent)

您已获得文件夹的全名:C:\ users \ OddThinking \ Documents \ My Source.您想将文件夹放在下面,然后将所有.src编译为.obj.

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)基本名称?

B)文件名?还是文件名?选择标识符名称时,区别很重要,在此我永远不会保持一致.

B) file name? Or is it 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 in in when required? What if there is no dot on a particular file?

H)路径名?还是等等,这只是路径吗?

H) path name? Or wait, is it just the path?

I)文件名.等等,这就是我所说的C. Path.等等,这就是我所说的H.也许H应该是文件夹名称.但是,文件夹"不是Windows专有术语吗?

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?

推荐答案

我认为您对标准"命名约定的搜索是徒劳的.这是我基于现有知名程序的建议:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆