What Is a Path? (And Other File System Facts)
来源:互联网 发布:java工程师岗位要求 编辑:程序博客网 时间:2024/05/24 15:38
http://docs.oracle.com/javase/tutorial/essential/io/path.html
What Is a Path? (And Other File System Facts)
A file system stores and organizes files on some form of media, generally one or more hard drives, in such a way that they can be easily retrieved. Most file systems in use today store the files in a tree (orhierarchical) structure. At the top of the tree is one (or more) root nodes. Under the root node, there are files and directories (folders in Microsoft Windows). Each directory can contain files and subdirectories, which in turn can contain files and subdirectories, and so on, potentially to an almost limitless depth.
This section covers the following:
- What Is a Path?
- Relative or Absolute?
- Symbolic Links
What Is a Path?
The following figure shows a sample directory tree containing a single root node. Microsoft Windows supports multiple root nodes. Each root node maps to a volume, such asC:\
or D:\
. The Solaris OS supports a single root node, which is denoted by the slash character,/
.
A file is identified by its path through the file system, beginning from the root node. For example, thestatusReport
file in the previous figure is described by the following notation in the Solaris OS:
/home/sally/statusReport
In Microsoft Windows, statusReport
is described by the following notation:
C:\home\sally\statusReport
The character used to separate the directory names (also called the delimiter) is specific to the file system: The Solaris OS uses the forward slash (/
), and Microsoft Windows uses the backslash slash (\
).
Relative or Absolute?
A path is either relative or absolute. An absolute path always contains the root element and the complete directory list required to locate the file. For example,/home/sally/statusReport
is an absolute path. All of the information needed to locate the file is contained in the path string.
A relative path needs to be combined with another path in order to access a file. For example,joe/foo
is a relative path. Without more information, a program cannot reliably locate thejoe/foo
directory in the file system.
Symbolic Links
File system objects are most typically directories or files. Everyone is familiar with these objects. But some file systems also support the notion of symbolic links. A symbolic link is also referred to as asymlink or a soft link.
A symbolic link is a special file that serves as a reference to another file. For the most part, symbolic links are transparent to applications, and operations on symbolic links are automatically redirected to the target of the link. (The file or directory being pointed to is called the target of the link.) Exceptions are when a symbolic link is deleted, or renamed in which case the link itself is deleted, or renamed and not the target of the link.
In the following figure, logFile
appears to be a regular file to the user, but it is actually a symbolic link todir/logs/HomeLogFile
. HomeLogFile
is the target of the link.
A symbolic link is usually transparent to the user. Reading or writing to a symbolic link is the same as reading or writing to any other file or directory.
The phrase resolving a link means to substitute the actual location in the file system for the symbolic link. In the example, resolvinglogFile
yields dir/logs/HomeLogFile
.
In real-world scenarios, most file systems make liberal use of symbolic links. Occasionally, a carelessly created symbolic link can cause a circular reference. A circular reference occurs when the target of a link points back to the original link. The circular reference might be indirect: directory a
points to directory b
, which points to directory c
, which contains a subdirectory pointing back to directorya
. Circular references can cause havoc when a program is recursively walking a directory structure. However, this scenario has been accounted for and will not cause your program to loop infinitely.
The next page discusses the heart of file I/O support in the Java programming language, thePath
class.
- What Is a Path? (And Other File System Facts)
- What is a Distributed System?
- what is a iml file?
- Configuring PATH and other environment variables in a bat file on Windows 7
- What is NetApp's Cluster File System?
- What is a Content Management System?
- What is a Perforce "shelved" file?
- What is a Perforce "shelved" file?
- What is the difference between Class Path and Build Path
- What is a texture and what is an Image
- what is a synthetic field and method
- What is Linux System Calls and Library Functions?
- What is Linux System Calls and Library Functions?
- What is Linux System Calls and Library Functions?
- What does “mounting a root file system” exactly means?
- What is a magic number? And why is it bad?
- What is System Administration?
- What is Operating System
- Liunx下查看服务器性能
- 关于fork()返回值
- spring+hibernate 配置、搭建
- android检查应用程序是否安装和检查服务是否启动的方法
- Eclipse使用技巧:快速设置字体
- What Is a Path? (And Other File System Facts)
- Android简单自定义控件做法
- iOS进阶面试题----多线程
- Windows下用Git下载android源码
- spring 事务特征、事务传播特征、事务隔离级别、 脏读、不可重复读、 幻觉读
- Mac OS X中打zip包时去除所有隐藏文件
- 我的android 第二天 - 短信发送器
- *exec,source和fork的区别*
- Liunx 分卷压缩和解压(zip和unzip)