digraph file_system_example {
"/" -> "a/" -> "d/";
"/" -> "dev/" -> "sda";
"/" -> "symlink_2";
"/" -> "e/";
"a/" -> "b/" -> "c/"
"b/" -> "e/ "; /* The space is a hack, not part of the vertex ID. */
"c/" -> "hello.txt"
"c/" -> "symlink_1"
}
Folder as a container is marked by
slash-suffix
. An element of a container is designated by omitting the
slash-suffix. The slash-suffixed path can be seen as a path to a "virtual file" that designates a set
of
container elements that form the whole content of the container.
Symlink
is just a special purpose file, a bit like device files and named pipes, regardless of its
state
or referenced object.
Upwards traversal is
designated by a
doubledot (..)
. Upwards traversal above root
/tmp/foo/../../../../../../../../../../../bar
is interpreted as starting from root
/bar
Triple-dots (...) are illegal by Linux or Bash implementation.
Absolute paths
are relative paths with the
working directory
of
/
To distinguish absolute pats from the rest of the relative paths, the absolute paths always start with
the
slash and the rest of the relative paths never start with the slash. For example, if the working
directory
were
/a/b
, then without that rule the
/e
and
/a/b/e
would be indistinguishable from each other.
Tilde (~
)
is one possible prefix of an absolute path, but
the tilde (
~
) can be used like
any other character in file names and folder names. Text editors like the
Vim use tilde as a suffix to some of its
temporary files. A path candidate like
xxxx~foo
is a valid relative path.
Some Path Normalization Rules
Table of Equivalent cases
|
/a//////b//c//////
|
/a/b/c/
|
././././././
|
./
|
./../
|
../
|
/a/./b/./
|
/a/b/
|
./a/
|
a/
|
./
|
.
|
../
|
..
|
./foo/../bar
|
./bar
|
/../../
|
/
|
~/../foo
|
/home/foo
|
~/../../foo
|
/foo
|