Path (computing)
403357
225564757
2008-07-14T09:47:55Z
MrVanBot
6913650
robot Adding: [[uk:Шлях (інформатика)]]
{{for|other meanings for this term|Path}}{{refimprove|date=July 2008}}
A '''path''' is the general form of a [[computer file|file]] or [[directory (file systems)|directory]] name, giving a file's name and its unique location in a [[file system]]. Paths point to their location using a [[string (computer science)|string]] of [[character (computing)|characters]] signifying directories, separated by a delimiting character, most commonly the [[Slash (punctuation)|slash]] "/" or [[backslash]] character "\", or colon ":" though some [[operating system]]s 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 Locator]]s (URLs).
A path can be either absolute or relative. A '''full path''' or '''absolute path''' is a path that points to the same [[location (file system)|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 and shell==
{| class="wikitable" style="font-size:90%"
|-
! Operating System
! Shell
! Parent-Child Direction
! Root Directory
! Directory Separator
|-
! [[Unix-like]] OS
| [[Unix shell]]
| Left-Right
| <code>/</code>
| <code>/</code>
|-
! [[DOS]]
| [[COMMAND.COM]]
| Left-Right
| <code>''[drive letter]'':\</code>
| <code>/</code> or <code>\</code>
|-
! [[OS/2]]
| [[cmd.exe]]
| Left-Right
| <code>''[drive letter]'':\</code>
| <code>/</code> or <code>\</code>
|-
! [[Microsoft Windows]]
| [[cmd.exe]]
| Left-Right
| <code>''[drive letter]'':/</code> or <code>''[drive letter]'':\</code>
| <code>/</code> or <code>\</code>
|-
! [[Microsoft Windows]]
| [[Windows PowerShell]]
| Left-Right
| <code>''[drive name]'':/</code> or <code>''[drive name]'':\</code> or<br />
<code>''[PSSnapIn name]''\''[PSProvider name]''::''[PSDrive root]''</code>
| <code>/</code> or <code>\</code>
|-
! [[OpenVMS]]
| [[DIGITAL Command Language|DCL]]
| Left-Right
| <code>''[device name]'':</code> or<br />
<code>''[NODE"accountname password"]''::''[device name]'':</code>
| <code>.</code>
|-
! [[Mac OS|Classic Mac OS]]
|
| Left-Right
| <code>''[drive name]'':</code>
| <code>:</code>
|-
! [[AmigaOS]]
| Amiga CLI / AmigaShell
| Left-Right
| <code>''[drive, volume or assign name]'':</code>
| <code>/</code>
|-
! [[RISC OS]]
| Task window
| Left-Right
| <code>''[fs type]''::''[drive number or disc name]''.$</code>
| <code>.</code>
|-
! [[Symbian OS]]
| File manager
| Left-Right
| <code>\</code>
| <code>\</code>
|-
! [[Domain/OS]]
| Shell
| Left-Right
| <code>//</code>
| <code>/</code>
|-
! [[MenuetOS]]/[[KolibriOS]]
| CMD
| Left-Right
| <code>/</code>
| <code>/</code>
|-
|}
On Japanese and Korean versions of Windows it may often look like the '[[¥]]' character or the '[[Won sign|₩]]' character is the path separator. This is not true however, instead the code for backslash is being drawn as these characters. Very early versions of MS-DOS replaced the backslash with these glyphs on the display to make it possible to display them by programs that only understood 7-bit [[ASCII]] (other characters such as the square brackets were replaced as well, see [[ISO 646]], [http://www.microsoft.com/GLOBALDEV/Reference/dbcs/932.htm Windows Codepage 932 (Japanese Shift JIS)], and [http://www.microsoft.com/GLOBALDEV/Reference/dbcs/949.htm Codepage 949 (Korean)]). This predates the addition of paths in MS-DOS 2 and is a good indication that Microsoft never intended backslash to be the path separator, as a normal slash would display correctly. Although even the first version of Windows supported the 8-bit [[ISO-8859-1]] character set which has the Yen sign at U+00A5, and modern versions of Windows supports [[Unicode]] which has the Won sign at U+20A9, much software will continue to display backslashes found in ASCII files this way to preserve backwards compatibility.
[[Mac OS X]] is UNIX-based and thus uses UNIX paths internally. However, to preserve compatibility for software and familiarity for users, many portions of the GUI switch "/" typed by the user to ":" internally, and switch them back when displaying filenames (a ":" entered by the user is also changed into "-" but the inverse translation does not happen).
==PATH variable==
On Unix-like operating systems, DOS, OS/2 and Microsoft Windows, 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:
\\ComputerName\SharedFolder\Resource
Note: The UNC syntax is sometimes written with forward slashes. In Windows the forward slashes and back slashes are equivalent, but many programs will accept only backward slashes, and some that will only accept *double* backslashes (ie \\\\ComputerName\\SharedFolder), especially in quoted string constants, due to the standard use of [[backslash]] as a [[Escape character]].
The "SharedFolder" is not necessarily the same as what a program on the server would see if it tries to open "\SharedFolder". Instead it is a name assigned to an arbitrary folder by the server when it made it "shared".
Unix-like systems occasionally use a similar syntax, but a [[POSIX]] requirement that double slashes must be treated as single slashes breaks this.{{Fact|date=April 2008}} More often this syntax is used:<ref>http://www.techweb.com/encyclopedia/defineterm.jhtml?term=UNC</ref>
ComputerName:/SharedFolder/Resource
or, like [[Uniform Resource Locator|URL]]s with the service name:
smb://ComputerName/SharedFolder/Resource
Some Windows APIs also accepts the "Long UNC":
\\?\UNC\ComputerName\SharedFolder\Resource
The different types of paths in Windows are local file system (LFS), such as <code>C:\File</code>, uniform naming convention (UNC), such as <code>\\Server\Volume\File</code>, and Long UNC or UNCW, such as <code>\\?\C:\File</code> or <code>\\?\UNC\Server\Volume\File</code>. In earlier versions of Windows only the API's that accept "Long UNC" would accept more than 260 characters. This has been fixed in recent versions.
==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 (file systems)|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 line interface|command prompt]] to change your current working directory to bobapples:
[[Cd (MS-DOS / Unix Command)|cd]] bobapples
Two dots ("<tt>..</tt>") are used for moving up in the [[hierarchy]], to indicate the [[parent directory]]; one dot ("<tt>.</tt>") represents the directory itself. Both can be components of a complex relative path (e.g., "<tt>../mark/./bobapples</tt>"), where "<tt>.</tt>" alone or as the first component of such a relative path represents the [[working directory]]. (Using "<tt>./foo</tt>" to refer to a file "<tt>foo</tt>" in the current working directory can sometimes be useful to distinguish it from a resource "<tt>foo</tt>" to be found in a default directory or by other means; for example, to view a specific version of a [[Unix manual|man page]] instead of the one installed in the system.)
===MS-DOS/Microsoft Windows style===
Contrary to popular belief, the [[Windows API|Windows system API]] accepts slash, and thus all the above Unix examples should work. But many applications on Windows interpret a slash for other purposes or think it is an invalid character, and thus require you to enter backslash. One of the prime examples is the cmd.exe shell (often called the "terminal" as it is typically run in a terminal window). Note that many other shells available for Windows, such as [[tcsh]] and [[Windows PowerShell]], allow the forward slash.
In addition "\" does not indicate a single root, but instead the root of the "current disk". Indicating a file on a disk other than the current one requires prefixing a drive letter and colon. This is not ambiguous because colon is not a valid character in an MS-DOS filename, and thus you cannot have a file called "A:" in your current directory.
Here are some examples of [[MS-DOS]]/[[Microsoft Windows|Windows]] style paths, with backslashes used to match the most common syntax:
A:\Temp\File
This path points to a file whose name is <tt>File</tt>, which is located in the directory <tt>Temp</tt>, which in turn is located in the root directory of the drive <tt>A:</tt>.
C:..\File
This path refers to a file called <tt>File</tt> located in the parent directory of the current directory on drive <tt>C:</tt>.
Folder\SubFolder\File
This path denotes a file called <tt>File</tt> located in <tt>SubFolder</tt> directory which in turn is located in <tt>Folder</tt> directory which is located in the current directory of the current drive (since no drive specification is present in this example).
File
This rather simple path points to a file named <code>File</code> located in the current directory (since no directory specification is present) on the current drive (since no drive specification is present).
\\.\COM1
This path refers to the first [[serial port]] ([[COM (hardware interface)|COM1]]).
==See also==
* [[Filename]]
* [[Uniform Resource Locator]] (URL)
* [[Device file]]
==References==
{{FOLDOC}}
{{reflist}}
==External links==
* [http://www.linfo.org/path.html Path Definition] - by The Linux Information Project (LINFO)
[[Category:Computer file systems]]
[[de:Uniform Naming Convention]]
[[es:Ruta (informática)]]
[[fr:Chemin d'accès]]
[[it:Pathname]]
[[uk:Шлях (інформатика)]]