引用路径和文件名的正确术语是什么?

发布于 2024-08-17 17:22:42 字数 264 浏览 2 评论 0原文

我想使用正确的术语使我的 API 尽可能直观,因此当参数预计是完整路径和文件名(例如“C:\Users\Max\Documents\MyDocument.txt”)时,正确的是什么学期?

  • 文件名 - 那就是 MyDocument.txt,对吧?
  • 路径 - 那就是 C:\Users\Max\Documents,对吗?

我应该使用什么作为参数名称? “文件”是合适的名称吗?

我觉得问这个问题有点愚蠢,但我想确保它是正确的。

I want to use the correct term to make my API as intuitive as possible, so when a parameter is expected to be a full path and filename (ex "C:\Users\Max\Documents\MyDocument.txt") what is the correct term?

  • filename - that would just be MyDocument.txt, right?
  • path - that would just be C:\Users\Max\Documents, right?

What should I use for the parameter name? Would "file" be the appropriate name?

I feel kind of dumb asking this, but I want to make sure it's right.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

终难遇 2024-08-24 17:22:42

对于指向文件的某些路径,我的建议是“绝对文件路径”,而我将使用“绝对目录路径”作为指向目录的路径

如果是相对路径,则更改应该是明显的。

如果没有别的事,您始终可以在文档中创建一个部分来描述您使用的某些术语的含义。

My suggestion would be "Absolute file path" for some path pointing to a file, where as i would use "Absolute directory path" for a path pointing to a directory

In case of relative paths the change should be obvious.

If nothing else, you can always make a section in your documentation where you describe the meaning of certain terms you use.

安静被遗忘 2024-08-24 17:22:42

正确的术语是“完全限定名称”(有时为“FQN”)。

您应该在 API 中使用的术语是“QualifiedName”或“QualifiedFilename”

维基百科有一个条目“完全限定文件名”,并将其定义为“计算机上的文件,其确切名称已完全指定,因此它是明确的,不会被误认为是该系统上的任何其他文件。”

The correct term is "Fully Qualified Name" (sometimes "FQN").

The term you should use in your API is "QualifiedName" or "QualifiedFilename"

Wikipedia has an entry for "Fully qualified file name" and defines it as "a file on a computer whose exact name is completely specified such that it is unambiguous and cannot be mistaken for any other file on that system."

盛装女皇 2024-08-24 17:22:42

经常过度使用的术语是 URI,尽管您的示例实际上并不是其中之一。我想如果您只使用“文件路径”或“路径名”,您就会非常清楚。

例如,Java 的文件对象使用“pathname”作为其 文件 对象。

A term often overused for this is URI, though your example isn't really one of those. I think you'll be perfectly clear if you just use "filepath" or "pathname."

For example, Java's file object uses "pathname" as the parameter name for the constructor on their File object.

铃予 2024-08-24 17:22:42

通常路径是完整的 C:\Users\Max\Documents\MyDocument.txtC:\Users\Max\Documents\ 部分通常称为基目录或者只是目录。

您会在很多示例代码中看到人们编写的:C:\path\to\the\document.txt

Usually path is the full C:\Users\Max\Documents\MyDocument.txt while the C:\Users\Max\Documents\ part is usually known as the base directory or just directory.

You'll see in a lot of example code people write: C:\path\to\the\document.txt

微凉徒眸意 2024-08-24 17:22:42

我会使用 fullPath 就像你说的路径是 C:\Users\Max\Documents 但读取 fullPath 会建议路径 + 文件名。

I'd go with fullPath like you said path would be C:\Users\Max\Documents but reading fullPath would suggest path + filename.

べ映画 2024-08-24 17:22:42

我认为没有一个正确的答案,也许有一些共识,但这就是我们所能希望的。我通常尝试遵循我正在使用的库的约定(例如,Cocoa、Java 或 PHP)。如果我没有什么可依据的,我会说:

  • 文件:名称引用的抽象事物:文件句柄
  • 路径:指示文件或目录位置的字符串,绝对或相对:/Users/Max/Documents/FooBar, ../Sibling/Zardoz
  • 名称:文件或目录的名称,不带位置:FooBar, <代码>Zardoz,文档

I don't think there is One True Answer, maybe some consensus, but that's all we can hope for. I usually try to follow the conventions of the library I'm using (e.g., Cocoa, Java, or PHP). If I've got nothing to go by, I'd say:

  • File: the abstract thing being referred to by a name: the file handle
  • Path: a string indicating the location of a file or directory, either absolute or relative: /Users/Max/Documents/FooBar, ../Sibling/Zardoz
  • Name: the name of the file or directory, without location: FooBar, Zardoz, Documents
诺曦 2024-08-24 17:22:42

您可能已经考虑过的一种更简单的解决方案是告诉 API 的使用者 XML 文档中期望什么,如果您使用文档编译程序集并分发 .xml 文件,该文档也将出现在 Visual Studio 智能感知中。

/// <summary>
/// Saves the provided file to disk.
/// </summary>
/// <param name="filePath">The full path, including the filename of the file.</param>
public void SaveFile(string filePath)
{

}

One easier solution you may have considered already is telling the consumer of the API what is expected in the XML documentation, which will also appear in Visual Studio intellisense if your compile the assembly with documentation, and distribute the .xml file.

/// <summary>
/// Saves the provided file to disk.
/// </summary>
/// <param name="filePath">The full path, including the filename of the file.</param>
public void SaveFile(string filePath)
{

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文