:''For other meanings for this term, see
Path''
A 'path' is the general form of a
file or
directory name, giving a file's name and its unique location in a
file system. Paths point to their location using a
string of
characters signifying directories, separated by a delimiting character, most commonly the
slash "/" or
backslash character "", though some
operating systems may use a different
delimiter. Paths are used extensively in
computer science to represent the directory/file relationships common in modern operating systems, and are essential in the construction of
Uniform Resource Locators (URLs).
A path can be either absolute or relative. A 'full path' or 'absolute path' is a path that points to the same
location on one file system regardless of the
working directory or combined paths. It is usually written in reference to a
root directory.
A 'relative path' is a path relative to the current
working directory, so the full absolute path may not need to be given.
Representations of paths by operating system
| | Unix-like operating system | DOS and descendant operating systems such as OS/2 and Microsoft Windows | Japanese version of Microsoft Windows | Korean version of Microsoft Windows | Classic Mac OS and Mac OS X | AmigaOS | RISC OS |
|---|
| Parent-Child Direction | Left-Right | Left-Right | Left-Right | Left-Right | Left-Right | Left-Right | Left-Right |
|---|
| Root Directory | / | ''[drive letter]'': | ''[drive letter]'': (may look like ''[drive letter]'':¥) | ''[drive letter]'': (may look like ''[drive letter]'':₩) | ''[drive name]'': | ''[drive, volume or assign name]'': | ''[fs type]''::''[drive number or disc name]''.$ |
|---|
| Directory Separator | / | or / | (may look like ¥) or / | (may look like ₩) or / | : | / | . |
|---|
Japanese version and Korean version Windows use the same
code point as the other versions—'U+005C' in Unicode, or '0x5C' in legacy code pages—as a path separator. However, the glyph of U+005C may look different in Japanese or Korean environments. It may look like the glyph of U+00A5 '
YEN SIGN' ¥ in Japanese fonts, or of U+20A9 '
WON SIGN' ₩ in Korean fonts. This does not mean that U+00A5 or U+20A9 may be used as a path separator. The difference only exists in the design of the character, and the path separator, although it may look like a different character, is identical in binary. Historically, 0x5C was mapped to YEN SIGN in Windows Codepage 932 (Japanese Shift JIS)
[1], and to WON SIGN in Codepage 949 (Korean)
[2], to make it easy to input the national currency symbol needed for practical purposes. Also note that 0x5C may appear as a part of a multibyte character (typically the trailing byte of a double-byte character) in
multibyte character sets, such as Japanese
Shift JIS, when it must not be interpreted as a path separator.
PATH variable
On
Unix-like operating systems,
DOS and its descendants, PATH is an
environment variable listing a set of paths to directories where executables may be found.
Uniform Naming Convention
The 'UNC', short for 'Universal Naming Convention' or 'Uniform Naming Convention', specifies a common syntax to describe the location of a network resource, such as a shared file, directory, or printer. The 'UNC' syntax for Windows systems is as follows:
\computernamesharedfolder
esource
where 'computername' is the
hostname, 'sharedfolder' is a shared directory with a name chosen by the host providing the share, and 'resource' is a shared directory, file, or printer. The hostname may also be identified by a
fully-qualified domain name or by
IP address. The 'sharedfolder' may exist anywhere on the remote host system, and is not restricted to the filesystem root directory.
Unix-like systems occasionally use a similar syntax, with forward slashes ( / ) in place of backslashes ( ), but usually write the syntax as computername:/directory/resource
[3] or, like
URLs, for example smb://computername/sharedfolder.
The UNC method started with the
UNIX operating system. UNIX systems use the forward-slash character as a path separator. Many network services such as
FTP have their origins in the UNIX operating system, so they use forward-slashes instead of the backslashes that DOS/Windows uses. It is important to recognize this distinction when using these services.
The "Long UNC" or "UNCW" format works with many - but not all - of the Windows 'W' ('W' suffix to the WinAPI routine, indicating wide, for wchar_t path names which are UCS2 based) looks as follows:
\?UNCComputerNameSharedVolumeResource
The different types of paths in Windows are local file system (LFS), such as
C:File.ext, uniform naming convention (UNC), such as
\ServerVolumeFile.ext, and Long UNC or UNCW, such as
\?C:File.ext or
\?UNCServerVolumeFile.ext.
One of the differences between LFS and UNC versus Long UNC is that LFS and UNC are limited to MAX_PATH (260 characters) and may be in ACP or UCS2 formats. Whereas Long UNC is limited to 30,000+ characters and must be in UCS2.
ACP stands for "ANSI Code Page", which is somewhat of a misnomer since none of the Windows code pages are actually ANSI compliant. The Windows operating system specifies a particular code page as the ACP, which then is used as the default / fallback code page for the 'A' suffixed path APIs. The ACP routines have the shortcoming in that they cannot represent all file paths that are representable in the operating system; they can only represent the character subset of Unicode UCS2 paths which have characters in the particular code page's character set.
Example
Unix style
Here is an example with a
Unix style
file system as it would appear from a terminal or terminal application (command-line window):
Your current working directory (cwd) is:
/users/mark/
You want to change your current working directory to:
/users/mark/bobapples
At that moment, the 'relative path' for the
directory you want is:
./bobapples
and the absolute path for the directory you want is
/users/mark/bobapples
Because ''bobapples'' is the 'relative path' for the directory you want, you may type the following at the
command prompt to change your current working directory to bobapples:
cd bobapples
Two dots ("
..") are used for moving up in the
hierarchy, to indicate the
parent directory; one dot ("
.") represents the directory itself. Both can be components of a complex relative path (e.g., "
../mark/./bobapples"), where "
." alone or as the first component of such a relative path represents the
working directory. (Using "
./foo" to refer to a file "
foo" in the current working directory can sometimes be useful to distinguish it from a resource "
foo" to be found in a default directory or by other means; for example, to view a specific version of a
man page instead of the one installed in the system.)
MS-DOS/Microsoft Windows style
Here are some examples of
MS-DOS/
Windows style paths:
A:Tempcar.jpg
This pathname points to a file whose name is
car.jpg, which is located in the directory
Temp, which in turn is located in the root directory of the drive
A:.
C:..Launch.avi
This pathname refers to a file called
Launch.avi located in the parent directory of the current directory on drive
C:.
Program FilesVieweriewer.exe
This pathname denotes a file called
viewer.exe located in
Viewer directory which in turn is located in
Program Files directory which is located in the current directory of the current drive (since no drive specification is present in this example).
viewer.exe
This rather simple pathname points to a file named
viewer.exe located in the current directory (since no directory specification is present) on the current drive (since no drive specification is present).
See also
★
Filename
★
Uniform Resource Locator (URL)
References
External Links
★
Path Definition - by The Linux Information Project (LINFO)