为什么一些windows文件和文件夹名称前面有一个点?

虽然我们大多数人在Windows系统上只看到普通的文件名和文件夹名,但其他人可能遇到了更出乎意料的事情——前面有一个点的文件名和文件夹名。为什么会这样?今天的超级用户问答帖子回答了一位非常好奇的读者的问题。...

为什么一些windows文件和文件夹名称前面有一个点?

虽然我们大多数人在Windows系统上只看到普通的文件名和文件夹名,但其他人可能遇到了更出乎意料的事情——前面有一个点的文件名和文件夹名。为什么会这样?今天的超级用户问答帖子回答了一位非常好奇的读者的问题。

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

照片由Domiriel(Flickr)提供。

问题

超级用户读者Niko Bellic想知道为什么某些Windows文件和文件夹名称前面有一个点:

For example, in the My Documents directory on my Windows system I have found the following folders:

  • .ssh
  • .subversion

Is this some sort of naming convention that I am unaware of?

为什么一些Windows文件和文件夹名称前面有一个点?

答案

超级用户贡献者grawity为我们提供了答案:

This naming convention comes from Unix-like operating systems (such as Linux or OSX) where it means a hidden file or directory. It works anywhere, but its primary use is to hide configuration files in your home directory (i.e. ~/.cache/ or ~/.plan) They are frequently called dot files.

Dot files could, in a way, be called the traditional Unix equivalent to the AppData directory on Windows. Meanwhile, many Linux programs are being changed to follow the XDG base directory specification, moving their configuration to ~/.config/ and other data to ~/.cache/ and ~/.local/share/. This makes it more similar to AppData\Roaming and AppData\Local.

You have these .ssh and .subversion directories on Windows because you have used some programs (specifically, OpenSSH and Subversion) that have been ported to use Windows system APIs rather than POSIX ones, but have not been adjusted for some other Windows conventi***.

Sometimes this adaptation is skipped intentionally to make life easier for people who use Unix-like environments such as Cygwin on their Windows systems. For example, Cygwin installs the standard set of Unix-like tools like ls, which ignores the Windows hidden flag and only honors the dot file names. It is also easier to synchronize configurati*** between an individual’s Windows and Linux/BSD/OSX computers if it is shared in the same location.

These files are typically found in the user’s home directory (i.e. /home/name/.ssh on Linux or C:\Users\name\.ssh on Windows 7 and later). It is quite rare for them to be put in the Documents or My Documents subdirectories (they do not contain documents after all).

As Rob Pike writes on Google+, this was an accidental feature:

Long ago, as the design of the Unix file system was being worked out, the entries . and .. appeared in order to make navigation easier. I am not sure, but I believe .. went in during Version 2’s rewrite when the file system became hierarchical (it had a very different structure early on). When one typed ls, however, these files appeared, so either Ken or Dennis added a simple test to the program. It was in assembler then, but the code in question was equivalent to something like this:

  • if (name[0] == ‘.’) continue;

This statement was a little shorter than what it should have been, which is:

  • if (strcmp(name, “.”) == 0 || strcmp(name, “..”) == 0) continue;

But hey, it was easy and two things resulted.

First, a bad precedent was set. A lot of other lazy programmers introduced bugs by making the same simplification. Actual files beginning with periods are often skipped when they should be counted.

Second, and much worse, the idea of a hidden or dot file was created. As a c***equence, more lazy programmers started dropping files into everyone’s home directory. I do not have much software installed on the computer I am using to type this, but my home directory has about one hundred dot files and I do not even know what most of them are or whether they are still needed. Every file name evaluation that goes through my home directory is slowed down by this accumulated sludge.


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-10 04:29
  • 阅读 ( 210 )
  • 分类:互联网

你可能感兴趣的文章

删除这些windows文件和文件夹以释放磁盘空间

...安全地删除以释放磁盘空间的Windows文件和文件夹,以及为什么要删除它们。请注意,其中一些文件夹位于受保护的位置,因此删除它们时要小心。 ...

  • 发布于 2021-03-11 09:22
  • 阅读 ( 365 )

可提高windows管理技能的powershell cmdlet

...让我们进行一些更改。可以使用get ChildItem命令获取任何文件夹的内容。例如,可以使用驱动器号获取整个驱动器的文件。输入: ...

  • 发布于 2021-03-13 13:26
  • 阅读 ( 286 )

完整的恶意软件删除指南

...恶意软件删除工作,HitmanPro可以抛出更多的结果。这就是为什么我们最后才用它来捡漏网的东西。像我们使用的其他一些工具一样,HitmanPro可以抛出一两个假阳性,所以在隔离前要仔细检查。 ...

  • 发布于 2021-03-14 00:00
  • 阅读 ( 246 )

7个你永远无法理解的windows谜团

... 让我们来看看这些谜团。你可能想知道为什么窗户在某些地方很特别,或者根本没有注意到它们。下面是你日常操作系统中一些神秘的小元素的答案。 ...

  • 发布于 2021-03-14 02:33
  • 阅读 ( 231 )

组织evernote的最佳方法:使用标记

... 你认为这个系统对你有用吗?如果没有,为什么? ...

  • 发布于 2021-03-15 05:02
  • 阅读 ( 187 )

使用这些工具自定义windows右键单击菜单

... 文件夹指南 ...

  • 发布于 2021-03-16 06:25
  • 阅读 ( 187 )

12+自定义windows键盘快捷键,适合你的极客

...按Windows键+R打开“多功能运行”命令,然后键入Shell:应用文件夹到打开文件资源管理器中的“应用程序”文件夹。 ...

  • 发布于 2021-03-16 17:33
  • 阅读 ( 574 )

11个奇怪的窗户虫子和复活节彩蛋

...,从结果中减去2。Windows计算器给你什么结果?明白他们为什么不让你在学校用计算器了吗? ...

  • 发布于 2021-03-25 13:30
  • 阅读 ( 305 )

如何在windows10中安装字体

... 下载新字体时,文件夹将包含看起来像一堆随机文件的内容。这些文件都是不同的字体样式,例如粗体、斜体、半粗体、粗斜体等等。文件的数量可能看起来很高,但是如果你想设计你的...

  • 发布于 2021-03-27 07:58
  • 阅读 ( 276 )

如何在Windows10上更改默认系统字体

...的位置,然后单击“保存” 打开保存新创建的注册表的文件夹。右键单击此文件并选择“合并”。这会将文件中的值添加到Windows注册表。 在提示符中单击“是”,然后再次单击“是”将新值添加到Windows注册表。 最后,单击...

  • 发布于 2021-03-31 11:16
  • 阅读 ( 232 )
kgks75702
kgks75702

0 篇文章

相关推荐