HOME

TheInfoList



OR:

A path is a
string String or strings may refer to: * String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * ''Strings'' (1991 film), a Canadian ani ...
of characters used to uniquely identify a location in a
directory structure In computing, a directory structure is the way an operating system arranges files that are accessible to the user. Files are typically displayed in a hierarchical tree structure. File names and extensions A filename is a string used to uniquely ...
. It is composed by following the directory tree hierarchy in which components, separated by a delimiting character, represent each directory. The delimiting character is most commonly the
slash Slash may refer to: * Slash (punctuation), the "/" character Arts and entertainment Fictional characters * Slash (Marvel Comics) * Slash (''Teenage Mutant Ninja Turtles'') Music * Harry Slash & The Slashtones, an American rock band * Nash ...
("/"), the
backslash The backslash is a typographical mark used mainly in computing and mathematics. It is the mirror image of the common slash . It is a relatively recent mark, first documented in the 1930s. History , efforts to identify either the origin ...
character ("\"), or colon (":"), though some
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s may use a different
delimiter A delimiter is a sequence of one or more characters for specifying the boundary between separate, independent regions in plain text, mathematical expressions or other data streams. An example of a delimiter is the comma character, which acts ...
. 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 A Uniform Resource Locator (URL), colloquially termed as a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifie ...
s (URLs). Resources can be represented by either ''absolute'' or ''relative'' paths.


History

Multics Multics ("Multiplexed Information and Computing Service") is an influential early time-sharing operating system based on the concept of a single-level memory.Dennis M. Ritchie, "The Evolution of the Unix Time-sharing System", Communications of t ...
first introduced a hierarchical file system with directories (separated by ">") in the mid-1960s. Around 1970,
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
introduced the slash character ("/") as its directory separator. In 1981, the first version of
Microsoft Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washingt ...
DOS DOS is shorthand for the MS-DOS and IBM PC DOS family of operating systems. DOS may also refer to: Computing * Data over signalling (DoS), multiplexing data onto a signalling channel * Denial-of-service attack (DoS), an attack on a communicatio ...
was released.
MS-DOS MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few oper ...
1.0 did not support file directories. Also, a major portion of the utility commands packaged with MS-DOS 1.0 came from IBM and their command line syntax used the slash character as a 'switch' prefix. For example, dir /w runs the dir command with the wide list format option. This use of slash can still be found in the command interface under
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for se ...
. By contrast, Unix uses the dash ("-") character as a command line switch prefix. When directory support was added to MS-DOS in version 2.0, "/" was kept as the switch prefix character for backwards compatibility. Microsoft chose the backslash character ("\") as a directory separator, which looks similar to the slash character, though more modern version of Windows are slash-agnostic, allowing mixage of both types of slashes in a path.


Absolute and relative paths

An absolute or full path points to the same location in a file system, regardless of the current
working directory In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd function, or just cu ...
. To do that, it must include the
root directory In a computer file system, and primarily used in the Unix and Unix-like operating systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the trunk of a tree, as the starting point where all branches ...
. By contrast, a relative path starts from some given working directory, avoiding the need to provide the full absolute path. A
filename A filename or file name is a name used to uniquely identify a computer file in a directory structure. Different file systems impose different restrictions on filename lengths. A filename may (depending on the file system) include: * name &ndas ...
can be considered as a relative path based at the current working directory. If the working directory is not the file's
parent directory In computing, a directory is a file system cataloging structure which contains references to other computer files, and possibly other directories. On many computers, directories are known as folders, or drawers, analogous to a workbench or the t ...
, a file not found error will result if the file is addressed by its name.


Representations of paths by operating system and shell

Japanese and Korean versions of Windows may often display the ' ¥' character or the ' ' character instead of the directory separator. In such cases the code for a 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 ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because of ...
(other characters such as the square brackets were replaced as well, see
ISO 646 ISO/IEC 646 is a set of ISO/ IEC standards, described as ''Information technology — ISO 7-bit coded character set for information interchange'' and developed in cooperation with ASCII at least since 1964. Since its first edition in ...

Windows Codepage 932 (Japanese Shift JIS)
an

. Although even the first version of Windows supported the 8-bit
ISO-8859-1 ISO/IEC 8859-1:1998, ''Information technology — 8-bit single-byte coded graphic character sets — Part 1: Latin alphabet No. 1'', is part of the ISO/IEC 8859 series of ASCII-based standard character encodings, first edition published in ...
character set which has the Yen sign at U+00A5, and modern versions of Windows supports
Unicode Unicode, formally The Unicode Standard,The formal version reference is is an information technology standard for the consistent encoding, representation, and handling of text expressed in most of the world's writing systems. The standard, whic ...
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 macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
, as a derivative of UNIX, 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).


Paths in programming languages

Programming languages also use paths. E.g.: When a file is opened. Most programming languages use the path representation of the underlying operating system: uxFile = fopen("project/readme.txt", "r") winFile = fopen("C:\\Program Files\\bin\\config.bat", "r") This direct access to the operating system paths can hinder the portability of programs. To support portable programs
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's most ...
uses ''File.separator'' to distinguish between / and \ separated paths.
Seed7 Seed7 is an extensible general-purpose programming language designed by Thomas Mertes. It is syntactically similar to Pascal and Ada. Along with many other features, it provides an extension mechanism. Daniel Zingaro"Modern Extensible Languages ...
has a different approach for the path representation. In Seed7 all paths use the Unix path convention, independent of the operating system. Under windows a mapping takes place (e.g.: The path ''/c/users'' is mapped to ''c:\users'').


Universal Naming Convention

The Microsoft Windows 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 has the generic form: \\ComputerName\SharedFolder\Resource Microsoft often refers to this as a "network path". Some Microsoft Windows interfaces also allow or require UNC syntax for
WebDAV WebDAV (Web Distributed Authoring and Versioning) is a set of extensions to the Hypertext Transfer Protocol (HTTP), which allows user agents to collaboratively author contents ''directly'' in an HTTP web server by providing facilities for conc ...
share access, rather than a URL. The UNC syntax is extended with optional components to denote use of SSL and TCP/IP port number, a WebDAV URL of http //HostName
Port A port is a maritime facility comprising one or more wharves or loading areas, where ships load and discharge cargo and passengers. Although usually situated on a sea coast or estuary, ports can also be found far inland, such as Ham ...
SharedFolder/Resource
becomes \\HostName
SSL SSL may refer to: Entertainment * RoboCup Small Size League, robotics football competition * '' Sesame Street Live'', a touring version of the children's television show * StarCraft II StarLeague, a Korean league in the video game Natural languag ...
@Port]\SharedFolder\Resource When viewed remotely, the "SharedFolder" may have a name different from what a program on the server sees when opening "\SharedFolder". Instead, the SharedFolder name consists of an arbitrary name assigned to the folder when defining its "sharing". Some Microsoft Windows interfaces also accept the "Long UNC": \\?\UNC\ComputerName\SharedFolder\Resource Microsoft Windows uses the following types of paths: * local file system (LFS), such as C:\File * universal naming convention (UNC), such as \\Server\Volume\File or / Directory name/code> (at least in Windows 7 and later) * "long" device path such as \\?\C:\File or \\?\UNC\Server\Volume\File. This path points to the local file namespace and is a similar one that points to the local DOS device namespace. This format is also the "raw" or "uninterpreted" path, since it sends paths straight to the file system without converting to and interpreting names like . * Windows NT object manager \\??\-prefixed paths (global DOS namespace). In versions of Windows prior to Windows XP, only the APIs that accept "long" device paths could accept more than 260 characters. The
shell Shell may refer to: Architecture and design * Shell (structure), a thin structure ** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses ** Thin-shell structure Science Biology * Seashell, a hard o ...
in
Windows XP Windows XP is a major release of Microsoft's Windows NT operating system. It was released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct upgrade to its predecessors, Windows 2000 for high-end and ...
and
Windows Vista Windows Vista is a major release of the Windows NT operating system developed by Microsoft. It was the direct successor to Windows XP, which was released five years before, at the time being the longest time span between successive releases of ...
,
explorer.exe File Explorer, previously known as Windows Explorer, is a file manager application that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user interface for accessing the file ...
, allows path names up to 248 characters long. Since UNCs start with two backslashes, and the backslash is also used for string escaping and in
regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" or ...
s, this can result in extreme cases of leaning toothpick syndrome: an escaped string for a regular expression matching a UNC begins with 8 backslashes – \\\\\\\\ – because the string and regular expression both require escaping. This can be simplified by using
raw string A string literal or anonymous string is a string value in the source code of a computer program. Modern programming languages commonly use a quoted sequence of characters, formally " bracketed delimiters", as in x = "foo", where "foo" is a strin ...
s, as in C#'s @"\\\\" or Python's r'\\\\', or regular expression literals, as in Perl's qr.


POSIX pathname definition

Most Unix-like systems use a similar syntax.
POSIX The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming interf ...
allows treating a path beginning with two slashes in an implementation-defined manner, though in other cases systems must treat multiple slashes as single slashes.POSIX pathname definition
/ref> Many applications on Unix-like systems (for example, scp, rcp and
rsync rsync is a utility for efficiently transferring and synchronizing files between a computer and a storage drive and across networked computers by comparing the modification times and sizes of files. It is commonly found on Unix-like opera ...
) use resource definitions such as: hostname:/directorypath/resource or
URI Uri may refer to: Places * Canton of Uri, a canton in Switzerland * Úri, a village and commune in Hungary * Uri, Iran, a village in East Azerbaijan Province * Uri, Jammu and Kashmir, a town in India * Uri (island), an island off Malakula Isla ...
schemes with the service name (here 'smb'): smb://hostname/directorypath/resource


Example


Unix style

The following worked example discusses the behavior of a
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
-style
file system In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one lar ...
as it would appear from a terminal or terminal application (command-line window): Attached to a current working directory (cwd) of: /users/mark/ One wants to change the current working directory to: /users/mark/bobapples At that moment, the relative path for the desired
directory Directory may refer to: * Directory (computing), or folder, a file system structure in which to store computer files * Directory (OpenVMS command) * Directory service, a software application for organizing information about a computer network's u ...
can be represented as: ./bobapples or for short: bobapples and the absolute path for the directory as: /users/mark/bobapples Given ''bobapples'' as the relative path for the directory wanted, the following may be typed at the command prompt to change the current working directory to bobapples: cd bobapples Two dots ("") point upwards in the
hierarchy A hierarchy (from Greek: , from , 'president of sacred rites') is an arrangement of items (objects, names, values, categories, etc.) that are represented as being "above", "below", or "at the same level as" one another. Hierarchy is an important ...
, to indicate the
parent directory In computing, a directory is a file system cataloging structure which contains references to other computer files, and possibly other directories. On many computers, directories are known as folders, or drawers, analogous to a workbench or the t ...
; one dot ("") represents the current directory itself. Both can be components of a complex relative path (e.g., ""), where "" alone or as the first component of such a relative path represents the
working directory In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd function, or just cu ...
. (Using "" to refer to a file "" in the current working directory can sometimes usefully distinguish it from a resource "" to be found in a default directory or by other means; for example, to view a specific version of a
manual page A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, an ...
instead of the one installed in the system.)


MS-DOS/Microsoft Windows style

Contrary to popular belief, the 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 treat it as an invalid character, and thus require you to enter backslash – notably the cmd.exe shell (often called the "terminal" as it typically runs in a terminal window). Note that many other shells available for Windows, such as
tcsh tcsh ( “tee-see-shell”, “tee-shell”, or as “tee see ess aitch”, tcsh) is a Unix shell based on and backward compatible with the C shell (csh). Shell It is essentially the C shell with programmable command-line completion, command-l ...
and
Windows PowerShell PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language. Initially a Windows component only, known as Windows PowerShell, it was made open-sourc ...
, allow the 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. No ambiguity ensues, because colon is not a valid character in an MS-DOS filename, and thus one cannot have a file called "A:" in the current directory. UNC names (any path starting with ) do not support slashes. The following examples show
MS-DOS MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few oper ...
/
Windows Windows is a group of several Proprietary software, proprietary graphical user interface, graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, W ...
-style paths, with backslashes used to match the most common syntax: A:\Temp\File.txt This path points to a file with the name , located in the directory , which in turn is located in the root directory of the drive . C:..\File.txt This path refers to a file called located in the parent directory of the current directory on drive . Folder\SubFolder\File.txt This path denotes a file called located in directory which in turn is located in directory which is located in the current directory of the current drive (since this example gives no drive-specification). File.txt This rather simple path points to a file named File.txt located in the current directory (since the path lacks a directory-specification) on the current drive (since no drive specification is present). \\.\COM1 This path refers to the first
serial port In computing, a serial port is a serial communication interface through which information transfers in or out sequentially one bit at a time. This is in contrast to a parallel port, which communicates multiple bits simultaneously in parallel. T ...
( COM1). C:\>more < C:/Windows/system.ini ; for 16-bit app support 86Enhwoafont=dosapp.fon EGA80WOA.FON=EGA80WOA.FON EGA40WOA.FON=EGA40WOA.FON CGA80WOA.FON=CGA80WOA.FON CGA40WOA.FON=CGA40WOA.FON ... This example uses a path containing slashes as directory separator. The command redirects the content of the file to the more command. E:\>dir "/Folder/SubFolder/" /Q Volume in drive E is Data Volume Serial Number is 07BE-0B10 Directory of E:\Folder\SubFolder 18 October 2008 08:15 AM DOMAIN\user . 18 October 2008 08:15 AM DOMAIN\user .. 18 October 2008 08:15 AM DOMAIN\user File.txt 1 File(s) 8 bytes 2 Dir(s) 19,063,000 bytes free A path containing forward slashes often needs to be surrounded by double quotes to disambiguate it from command line switches. *note: CD does not work this way: CD " rive letter/Program Files" will only work from the root ( rive letter\) directory. This appears to treat all forward slashes the same as .\. *exception: Use the /D switch to change current drive in addition to changing current directory for a drive. For example: CD "C:.\Program Files" works the same as CD "C:/Program Files" Also, from a root folder: CD "C:.\Program Files.\Internet Explorer" would be treated the same as CD "C:/Program Files/Internet Explorer" If there is no relative path to the directory name specified with forward slashes you will get the following error: The system cannot find the path specified. For setting environment variables, it is sometimes necessary to provide a path that does not contain spaces in it, for instance defined as "C:\Program Files\Java..." can cause scripts to halt when they encounter the space in the path name. To get the eight-character name Windows assigns to any directory for substitution in environment variables, use the directory listing command with the /x option one level up from the target directory. For instance, the following will get you the eight character name for all directories directly under root: C:\>dir /x


See also

*
Filename A filename or file name is a name used to uniquely identify a computer file in a directory structure. Different file systems impose different restrictions on filename lengths. A filename may (depending on the file system) include: * name &ndas ...
*
basename basename is a standard computer program on Unix and Unix-like operating systems. When basename is given a pathname, it will delete any prefix up to the last slash ('/') character and return the result. basename is described in the Single UNIX ...
*
Device file In Unix-like operating systems, a device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. There are also special files in DOS, OS/2, and Windows. These special files allow a ...
*
dirname dirname is a standard computer program on Unix and Unix-like operating systems. When dirname is given a pathname, it will delete any suffix beginning with the last slash ('/') character and return the result. dirname is described in the Single U ...
*
Distributed file system A clustered file system is a file system which is shared by being simultaneously mounted on multiple servers. There are several approaches to clustering, most of which do not employ a clustered file system (only direct attached storage for ...
(DFS) *
Filesystem Hierarchy Standard The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of a UNIX system. It has been made popular by its use in Linux distributions, but it is used by other UNIX variants as well. It is maintained b ...
(FHS) * Fully qualified file name *
PATH (variable) PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting. ...
*
Uniform Resource Locator A Uniform Resource Locator (URL), colloquially termed as a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifie ...
(URL)


References


External links


Path Definition
- The Linux Information Project (LINFO)
Naming Files, Paths, and Namespaces
- Local File Systems : Windows :
Microsoft Docs Microsoft Docs is the library of technical documentation for end users, developers, and IT professionals who work with Microsoft products. The Microsoft Docs website provides technical specifications, conceptual articles, tutorials, guides, API ...
{{DEFAULTSORT:Path (computing) Computer file systems