文件系统是否具有其他组件,而不是文件和目录? [英] Do file systems have other components rather than files and directories?
问题描述
我在视频教程中看到了这个python代码段,该代码段检查列出的项目是目录还是文件:
I have seen this python snippet in a video tutorial which checks if the listed item is a directory or a file:
for item in os.listdir("."):
if os.path.isfile(item):
# do something
elif os.path.isdir(item):
# do somethin
else:
# What is this case ?!
else语句是否有可能被击中?
is it possible that the else statement could be hit?
推荐答案
正如@sisoft所说,简单的答案是肯定的:确实存在支持文件和目录以外的文件类型的文件系统.
As @sisoft says, the simple answer is yes: there do exist file systems that support file types other than files and directories.
如果您感兴趣的话,更长的答案是文件系统支持的类型随文件系统的不同而有很大差异. UNIX将大量事物视为文件"(意味着文件系统中的对象),因此具有许多类型. Windows具有一组更受限制的对象(我相信文件,目录和链接(无源))
The longer answer, if you're interested, is that the types supported by a file system vary wildly with the file system. UNIX treats a huge number of things as a 'file' (meaning an object in the file system) and so has many types. Windows has a more restricted set of objects (files, directories and links only I believe (no source))
文件系统的POSIX规范(由许多文件系统实现)未指定文件系统必须支持的对象(
The POSIX specification (implemented by many file systems) for a file system doesn't specify what objects it must support(source).
通常,文件系统是一个相当开放的术语,可以引用任何对象存储.它存储的对象可以是任何东西.
Generally, file system is a fairly open term that can refer to any object store. The objects that it stores could be anything.
如果您想了解有关文件系统的更多信息,请参阅操作系统,它提供了易于访问的介绍.
If you'd like to learn more about file systems, there is a great chapter in Operating Systems which gives an easily accessible introduction.
这篇关于文件系统是否具有其他组件,而不是文件和目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!