Path (computing)
- 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 folder/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 | Classic Mac OS | AmigaOS | RISC OS | Korean version of Microsoft Windows | |
---|---|---|---|---|---|---|---|
Parent-Child Direction | Left-Right | Left-Right | Left-Right | Left-Right | Left-Right | Left-Right | Left-Right |
Root Directory | / | <drive letter>:\ | <drive letter>:¥ | <drive name>: | <drive, volume or assign name>: | <fs type>::<drive number or disc name>.$ | <drive letter>:₩ |
Directory Separator | / | \ | ¥ | : | / | . | ₩ |
PATH variable
On Unix-like operating systems and on DOS and its descendants, PATH is an environment variable listing a set of paths to directories where executables may be found.
Universal Naming Convention
The Universal Naming Convention, or UNC, 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:
\\computername\sharedfolder\resource
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 [1] 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:
\\?\UNC\ComputerName\SharedVolume\Resource
The different types of paths in Windows is LFS (local file system, such as C:\File.ext
), UNC (universal naming convention, such as \\Server\Volume\File.ext
), and Long UNC or UNCW (such as \\?\C:\File.ext
or \\?\UNC\Server\Volume\File.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:\Temp\car.jpeg
This pathname points to a file whose name is car.jpeg, 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 Files\Viewer\viewer.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
References
This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.