Path (computing): Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>Ernstkm
Universal naming convention: there is an inbound link from the disambiguation page for "UNC" that points to the upper-case version; this edit will fix that broken redirect. UNC is an acronym anyway, and as such, should remain capitalized.
 
imported>SchmuckyTheCat
 
Line 1: Line 1:
{{Short description|Text that specifies a file system item in a directory structure}}
{{Short description|Text that identifies an item in a computer file system}}
{{Use dmy dates|date=March 2020}}
{{For|the environment variable|PATH (variable)}}
{{For|the environment variable|PATH (variable)}}
{{More citations needed|date=July 2008}}
{{Use dmy dates|date=March 2020}}
A '''path''' (or '''filepath''', '''file path''', '''pathname''', or similar) is a [[string (computer science)|text string]] that uniquely specifies an item in a [[hierarchical file system]]. Generally, a path is composed of directory names, special directory specifiers and optionally a [[filename]], separated by [[delimiter|delimiting text]]. The delimiter varies by operating system and in theory can be anything, but popular, modern systems use [[slash (punctuation)|slash]] {{code|/}}, [[backslash]] {{code|\}}, or colon {{code|:}}.


A path can be either relative or absolute. A relative path includes information that is relative to a particular directory whereas an absolute path indicates a location relative to the system [[root directory]], and therefore, does not depends on context like a relative path does. Often, a relative path is relative to the [[working directory]]. For example, in command {{code|ls f}}, {{code|f}} is a relative path to the file with that name in the working directory.
A '''path''' (or '''filepath''', '''file path''', '''pathname''', or similar) is a [[string (computer science)|string]] that uniquely identifies an item in a [[hierarchical file system]]. Generally, a path is composed of directory names, special format specifiers, and optionally a [[filename]], all separated by [[delimiters]]. This delimiter can vary by operating system, but popular, modern systems use the [[slash (punctuation)|slash]] {{code|/}}, [[backslash]] {{code|\}}, or [[Colon (punctuation)|colon]] {{code|:}}.
 
The [[case sensitivity|case-sensitivity]] of individual path components will vary based on [[operating system]], or based on options specified at the time of a file system's [[mkfs|creation]] or [[Mount (computing)|first use]]. In practice, this means that for a '''case-sensitive''' system, path components named {{code|component1}} and {{code|Component1}} can coexist at the same level in the hierarchy, whereas for a '''case-''in''sensitive''' file system, they cannot (an error will occur). macOS and Windows' native file systems are case-insensitive by default, whereas typical Linux file systems are case-sensitive.<ref>{{Cite web |title=File system formats available in Disk Utility on Mac |url=https://support.apple.com/guide/disk-utility/file-system-formats-dsku19ed921c/mac |access-date=2025-09-12 |website=Apple Support |language=en}} Includes a description of [[APFS]], the default file system for macOS</ref><ref>{{Cite web |last=Matt Wojciakowski |title=Case Sensitivity |url=https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity |access-date=2025-09-12 |website=learn.microsoft.com |language=en-us}} <q>Windows file system treats file and directory names as case-insensitive. FOO.txt and foo.txt will be treated as equivalent files. Linux file system treats file and directory names as case-sensitive. FOO.txt and foo.txt will be treated as distinct files.</q></ref><ref>{{Cite web |last=Day |first=Brittany |title=Understanding the Linux Filesystem Case Sensitivity Debate |url=https://linuxsecurity.com/features/linux-filesystem-case-sensitivity-debate |access-date=2025-09-12 |website=Linux Security |language=en-gb}} <q>Case sensitivity in Linux refers to files and directories recognizing differences between lowercase and uppercase characters in filenames. For instance, "File.txt" and "file.txt" would both be treated as two distinct files. This concept is integral to Unix-like operating systems, including Linux.</q></ref>
 
{{anchor |relative}}{{anchor |absolute}}A path can be either '''relative''' or '''absolute'''. A relative path is a path in relation to another, most often the [[working directory]]. An absolute path indicates a location regardless of the current directory; that is, it specifies all path components starting from the file system's [[Root directory|root]], and does not depend on context like a relative path does.


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|uniform resource locators]] (URLs).
Paths are also essential for locating hierarchically-organized network resources, as seen in [[Uniform resource locator|URLs]] and [[#Universal Naming Convention|UNC paths]].


==History==
== History ==
[[Multics]] first introduced a [[hierarchical file system]] with directories (separated by ">") in the mid-1960s.<ref>{{cite conference |last1=Daley |first1=R.C. |last2=Neumann |first2=P.G. |book-title=Proceedings of the November 30--December 1, 1965, fall joint computer conference, Part I on XX - AFIPS '65 (Fall, part I) |title=A general-purpose file system for secondary storage |date=1965 |volume=Part I |pages=213–229 |doi=10.1145/1463891.1463915 |doi-access=free |s2cid=16236414}}</ref>
[[Multics]] first introduced a [[hierarchical file system]] with directories (separated by ">") in the mid-1960s.<ref>{{cite conference |last1=Daley |first1=R.C. |last2=Neumann |first2=P.G. |date=1965 |title=A general-purpose file system for secondary storage |volume=Part I |pages=213–229 |doi=10.1145/1463891.1463915 |doi-access=free |book-title=Proceedings of the November 30--December 1, 1965, fall joint computer conference, Part I on XX - AFIPS '65 (Fall, part I) |s2cid=16236414}}</ref>


Around 1970, [[Unix]] introduced the slash character ("/") as its directory separator.
Around 1970, [[Unix]] introduced the slash {{code|/}} as its directory separator.


Originally, [[MS-DOS]] did not support directories, but when adding the feature, using the Unix standard of slash was not a good option since many existing commands used slash as the [[command-line switch|switch]] prefix. For example, <code>dir /w</code>. In contrast, Unix uses dash {{code|-}} as the switch prefix. In this context, MS-DOS version 2.0 used backslash {{code|\}} for the path delimiter since it is similar to slash but did not conflict with existing commands. This convention continued into [[Windows]] in its shell [[Command Prompt]]. Eventually, [[PowerShell]], was introduced to Windows that is slash-agnostic, allowing the use of either slash in a path.<ref>{{cite web |title=Why Windows Uses Backslashes and Everything else Uses Forward Slashes |date=10 February 2014 |url=https://www.howtogeek.com/181774/why-windows-uses-backslashes-and-everything-else-uses-forward-slashes/}}</ref><ref>{{cite web |title=Why is the DOS path character ""? |url=https://learn.microsoft.com/archive/blogs/larryosterman/why-is-the-dos-path-character |date=24 June 2005}}</ref>
Originally, [[MS-DOS]] did not support directories. When adding the feature, using the Unix standard of a slash was not a good option since many existing commands used a slash as the [[command-line switch|switch]] prefix (i.e., {{code|dir /w}}). In contrast, Unix uses the dash {{code|-}} as the switch prefix. The backslash {{code|\}} was ultimately chosen instead for its similarity to the slash and not conflicting with existing commands. This convention continued into [[Windows]]. However, some areas of Windows do accept or understand Unix-style slashes also, such as [[PowerShell]].<ref>{{cite web |date=10 February 2014 |title=Why Windows Uses Backslashes and Everything else Uses Forward Slashes |url=https://www.howtogeek.com/181774/why-windows-uses-backslashes-and-everything-else-uses-forward-slashes/}}</ref><ref>{{cite web |date=24 June 2005 |title=Why is the DOS path character "\"? |url=https://learn.microsoft.com/archive/blogs/larryosterman/why-is-the-dos-path-character}}</ref>


==Path syntax==
== Summary of systems ==
<!--
<!--
Pathing is more a feature of the file system; not the OS or the shell, but this table focuses on OS and shell :(
Pathing is more a feature of the file system; not the OS or the shell, but this table focuses on OS and shell :(
-->
-->
The following table describes the syntax of paths in notable operating systems and with notable aspects by shell.
The following table describes the syntax of paths in notable operating systems:{{Table alignment}}
 
{| class="wikitable mw-collapsible mw-collapsed col3center col4center col5center col6center" style="font-size: 90%;"
{{Table alignment}}
{| class="wikitable col3center col4center col5center col6center" style="font-size:90%;"
|-
|-
! Context
! System
! Root<br>dir
! Root dir.
! Path<br>delim
! Path delim.
! Working<br>dir
! Working dir.
! Parent<br>dir
! Parent dir.
! Home<br>dir
! Home dir.
! Examples
! Examples
|-
|-
! [[Unix]]
! [[Unix]] and [[Unix-like]] systems, including [[macOS]]<ref>{{Cite web |date=2018-04-09 |title=File System Basics |url=https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html |access-date=2025-09-07 |website=developer.apple.com}}</ref>
| <code>/</code>
| {{mono|/}}
| <code>/</code>
| {{mono|/}}
| <code>.</code>
| {{mono|.}}
| <code>..</code>
| {{mono|..}}
| <code>~</code>
| {{mono|~}}
| <code>/home/user/docs/Letter.txt</code><br><code>./inthisdir</code><br><code>../../greatgrandparent</code><br><code>~/.rcinfo</code>
| {{mono|/home/user/docs/Letter.txt}}<br>{{mono|./child}}<br>{{mono|../../greatgrandparent}}<br>{{mono|~/.rcinfo}}
|-
! [[Microsoft Windows|Windows]], [[Command Prompt]]
| {{mono|\}} (relative to current working directory root)<br>or {{mono|[drive letter]:\}}<br>or {{Mono|\\.\}}<br>or {{Mono|\\?\}}<br>or UNC
| {{mono|/}}{{efn|name="windows-fslash"|Limited compatibility, may not work in all Windows programs}}<br>or {{mono|\}}
| {{mono|.}}
| {{mono|..}}
|
| {{mono|C:\user\docs\Letter.txt}}<br>{{mono|/user/docs/Letter.txt}}{{mono|C:\user\docs\somefile.ext:[[NTFS#Alternate data stream (ADS)|alternate stream name]]}}
{{Mono|C:picture.jpg}}<br>{{mono|\\?\UNC\Server01\user\docs\Letter.txt}}<br>{{Mono|\\.\COM1}}
|-
! [[PowerShell]]
| {{mono|[drive letter]:/}}<br>or {{mono|[drive name]:\}}<br>or {{mono|[PSSnapIn name]\[PSProvider name]::[PSDrive root]}}<br>or UNC
| {{mono|/}}{{efn|name="windows-fslash"}}<br>or {{mono|\}}
| {{mono|.}}
| {{mono|..}}
| {{mono|~}}
| {{mono|C:\user\docs\Letter.txt}}<br>{{mono|~\Desktop}}{{mono|UserDocs:/Letter.txt}}<br>{{mono|Variable:PSVersionTable}}<br>{{mono|Registry::HKEY_LOCAL_MACHINE\SOFTWARE\}}<br>{{mono|Microsoft.PowerShell.Security\Certificate::CurrentUser\}}
|-
|-
! [[DOS]] [[COMMAND.COM]]
![[Path (computing)#Universal Naming Convention|UNC]]<ref>{{Cite web |title=UNC Network Share Access (Windows) |url=https://www.ibm.com/docs/en/iodg/11.3.0?topic=credentials-unc-network-share-access-windows |access-date=2025-09-07 |website=www.ibm.com |language=en-us}}</ref>
| <code>''[drive letter:]''\</code><br>or <code>\\''[server name]''\''[volume]''\</code>
|{{mono|\\[server]\[sharename]\}}
| <code>\</code>
|{{Mono|/}}
| <code>.</code>
|
| <code>..</code>
|
|  
|
| <code>C:\USER\DOCS\LETTER.TXT</code><br><code>A:PICTURE.JPG</code><br><code>\\SERVER01\USER\DOCS\LETTER.TXT</code>
|{{mono|\\Server01\user\docs\Letter.txt}}
|-
|-
! [[OS/2]] [[cmd.exe]]
! [[DOS]], [[COMMAND.COM]]
| <code>''[drive letter:]''\</code><br>or <code>\\''[server name]''\''[volume]''\</code>
| {{mono|[drive letter]:\}}<br>or {{mono|\\[server name]\[volume]\}}
| <code>/</code><br>or<br><code>\</code>
| {{mono|\}}
| <code>.</code>
| {{mono|.}}
| <code>..</code>
| {{mono|..}}
|  
|  
| <code>C:\user\docs\Letter.txt</code><br><code>A:Picture.jpg</code><br><code>\\SERVER01\USER\docs\Letter.txt</code>
| {{mono|C:\USER\DOCS\LETTER.TXT}}<br>{{mono|A:PICTURE.JPG}}<br>{{mono|\\SERVER01\USER\DOCS\LETTER.TXT}}
|-
|-
! [[Microsoft Windows|Windows]] [[Command Prompt]]
! [[OS/2]]
| <span style="white-space:nowrap;"><code>\</code> (relative to current working directory root)</span><br>or <code>''[drive_letter]'':\</code><br>or <code style="white-space:nowrap;">\\''[server]''\''[sharename]''\</code><br>or <code style="white-space:nowrap;">\\?\''[drive_spec]'':\</code><br>or&nbsp;<code style="white-space:nowrap;">\\?\UNC\''[server]''\''[sharename]''\</code><br>or <code style="white-space:nowrap;">\\.\''[physical_device]''\</code><ref name="w32paths">{{cite web |title=Naming Files, Paths, and Namespaces |website=[[Microsoft Docs]] |date=15 December 2022 |url=https://learn.microsoft.com/windows/win32/fileio/naming-a-file}}</ref>
| {{mono|[drive letter]:\}}<br>or {{mono|\\[server name]\[volume]\}}
| <code>/</code><br>or<br><code>\</code>
| {{mono|/}}<br>or {{mono|\}}
| <code>.</code>
| {{mono|.}}
| <code>..</code><ref>{{cite web |title=cd |department=Windows Commands: Windows Server |website=[[Microsoft Docs]] |date=3 February 2023 |url=https://learn.microsoft.com/windows-server/administration/windows-commands/cd |access-date=2023-10-04}}</ref>
| {{mono|..}}
|  
|  
| <code>C:\user\docs\Letter.txt</code><br><code>/user/docs/Letter.txt</code><br><code>C:\Letter.txt</code><br><code>\\Server01\user\docs\Letter.txt</code><br><code>\\?\UNC\Server01\user\docs\Letter.txt</code><br><code>\\?\C:\user\docs\Letter.txt</code><br><code><span style="white-space:nowrap;">C:\user\docs\somefile.ext:[[NTFS#Alternate data stream (ADS)|alternate stream name]]</span></code><br><code>./inthisdir</code><br><code>../../greatgrandparent</code><br>
| {{mono|C:\user\docs\Letter.txt}}<br>{{mono|A:Picture.jpg}}<br>{{mono|\\SERVER01\USER\docs\Letter.txt}}
|-
|-
! [[Windows]] [[PowerShell]]
! [[RSX-11]] MCR<ref>{{Cite book |title=RSX-11M-PLUS MCR Operations Manual |date=August 1987 |publisher=[[Digital Equipment Corporation]] |edition=4th |pages=26-31}}</ref>
| <code>''[drive letter:]''/</code><br>or <code>''[drive name:]''\</code><br>or <code>\\''[server name]''\</code><br>or <code>''[PSSnapIn name]''\''[PSProvider name:][:PSDrive root]''</code>
| {{mono|[device name]:}}
| <code>/</code><br>or<br><code>\</code>
|
| <code>.</code>
|
| <code>..</code>
|
| <code>~</code>
|
| <code>C:\user\docs\Letter.txt</code><br><code>C:\user/docs\Letter.txt</code><br><code>\\Server01\user\docs\Letter.txt</code><br><code>cd ~\Desktop</code><br>
| {{mono|DR0:[30,12]LETTER.TXT;4}}{{efn|In order, the fields are {{code|ddnn:[g,m]:filename.type;version}}}}
<code>UserDocs:/Letter.txt</code><br>
<code>Variable:PSVersionTable</code><br>
<code>Registry::HKEY_LOCAL_MACHINE\SOFTWARE\</code><br>
<code>Microsoft.PowerShell.Security\Certificate::CurrentUser\</code>
|-
|-
! [[TOPS-20]] [[DIGITAL Command Language|DCL]]
! [[TOPS-20]] [[DIGITAL Command Language|DCL]]<ref>{{Cite tech report |url=https://apps.dtic.mil/sti/html/tr/ADA163675/index.html |title=Defense Data Network/TOPS-20 Tutorial. An Interative Computer Program. |last=Herkert |first=Mark Klause Herman |last2=Smith |first2=Sheri Lynn |date=December 1985 |format=PDF}}</ref>
| <code>''[device name:]''</code>
| {{mono|[device name]:}}
| <code>.</code>
| {{mono|.}}
|  
|  
|  
|  
|  
|  
| <code>PS:<USER.DOCS>LETTER.TXT,4</code>
| {{mono|PS:<USER.DOCS>LETTER.TXT,4}}
|-
|-
! [[RSX-11]] MCR
! [[OpenVMS]] [[DIGITAL Command Language|DCL]]<ref>{{Cite web |last=Rabe |first=Bernhard |date=2011-06-06 |title=OpenVMS & DCL on Alpha & VAX |url=https://osm.hpi.de/serveros/2011/OpenVMS/uebung/OpenVMS-DCL.pdf}}</ref><ref>{{Cite web |date=2025 |title=VSI OpenVMS User's Manual |url=https://docs.vmssoftware.com/docs/vsi-openvms-user-s-manual.pdf |access-date=2025-09-07 |website=VMS Software}}</ref>
| <code>''[device name:]''</code>
| {{mono|[device name]:[000000]}}<br>or {{mono|<nowiki>[NODE["accountname password"]]::[device name][000000]:</nowiki>}}
|  
| {{mono|.}}
|  
| {{mono|[]}}
|  
| {{mono|[-]}}
|  
| <small>{{mono|SYS$LOGIN:}}</small>
| <code>DR0:[30,12]LETTER.TXT;4</code>
| {{mono|NODE$DISK:[USER.DOCS]PHOTO.JPG}}{{Mono|USER:[000000]000000.DIR}}{{mono|[]IN_THIS_DIR.COM;}}<br>{{mono|[-.-]GreatGrandParent.TXT}}<br>{{mono|SYS$SYSDEVICE:[.DRAFTS]LETTER.TXT;4}}<br>{{mono|GEIN::[000000]LETTER.TXT;4}}<br>{{mono|SYS$LOGIN:LOGIN.COM}}
|-
|-
! [[OpenVMS]] [[DIGITAL Command Language|DCL]]
! [[Apple ProDOS|ProDOS]] AppleSoft BASIC<ref>{{Cite book |title=ProDOS User's Manual |publisher=[[Apple Computer]] |year=1983 |pages=56-62}}</ref>
| <code>''[device name:]''[000000]</code><br>or <code>''[NODE["accountname password"]]''::''[device name]''[000000]:</code>
| {{mono|/[volume or drive name]/}}
| <code>.</code>
| {{mono|/}}
| <code>[]</code>
|
| <code>[-]</code>
|
| <small><code>SYS$LOGIN:</code></small>
|
| <code>SYS$SYSDEVICE:[USER.DOCS]PHOTO.JPG</code>
| {{mono|/SCHOOL.DISK/APPLEWORKS/MY.REPORT}}{{mono|FLIGHT.SIMULATOR,D2}}
<code>[]IN_THIS_DIR.COM;</code><br>
<code>[-.-]GreatGrandParent.TXT</code><br>
<code>SYS$SYSDEVICE:[.DRAFTS]LETTER.TXT;4</code><br>
<code>GEIN::[000000]LETTER.TXT;4</code><br>
<code>SYS$LOGIN:LOGIN.COM</code><br>
|-
|-
! [[Classic Mac OS|Classic<br>Mac OS]]
! [[AmigaOS]] Amiga CLI / AmigaShell<ref>{{Cite book |title=The AmigaDOS Manual |date=February 1986 |publisher=Bantam Computer Books |others=Produced by Commodore-Amiga, Inc. |isbn=978-0-553-34294-9 |pages=6-16}}</ref>
| <code>''[volume or drive name]'':</code>
| {{mono|[drive, volume, device, or assign name]:}}
| <code>:</code>
| {{mono|/}}
| <code>:</code>
| ''empty string''
| <code>::</code>
| {{mono|/}}
|  
|
| <code>Macintosh HD:Documents:Letter</code><br><code>:fileincurrentdir</code><br><code>::fileinparent</code><br><code>:::fileingrandparent</code>
| {{mono|Workbench:Utilities/MultiView}}<br>{{mono|DF0:S/Startup-Sequence}}<br>{{mono|S:Startup-Sequence}}<br>{{mono|TCP:en.wikipedia.com/80}}
|-
! [[Apple ProDOS|ProDOS]] AppleSoft BASIC
| <code>/''[volume or drive name]''/</code>
| <code>/</code>
|
|
|
| <code>/SCHOOL.DISK/APPLEWORKS/MY.REPORT</code>
<code>FLIGHT.SIMULATOR,D2</code>
|-
! [[AmigaOS]] Amiga CLI /<br>AmigaShell
| <code>''[drive, volume, device, or assign name]:''</code>
| <code>/</code>
| ''empty<br>string''
| <code>/</code>
|  
| <code>Workbench:Utilities/MultiView</code><br><code>DF0:S/Startup-Sequence</code><br><code>S:Startup-Sequence</code><br><code>TCP:en.wikipedia.com/80</code>
|-
|-
! [[RISC OS]] ShellCLI
! [[RISC OS]] ShellCLI<ref>{{Cite web |date=2015-11-03 |title=RISC OS PRMs: Volume 2: Chapter 44: Writing a filing system |url=http://www.riscos.com/support/developers/prm/writefs.html |access-date=2025-09-07 |website=www.riscos.com Technical Support: Programmer's Reference Manual |publisher=3QD Developments Ltd.}}</ref>
| <code>''[fs type[#option]:][:drive number or disc name.]''$</code>
| {{mono|[fs type[#option]:][:drive number or disc name.]$}}{{efn|{{code|&}}, {{code|%}}, and {{code|@}} can also be used to reference the root of the current user, the library, and the current directory respectively}}
note: &, %, and @ can also be used to reference the root<br>of the current user, the library and the current (working) directory respectively.
| {{mono|.}}
| <code>.</code>
| {{mono|@}}
| <code>@</code>
| {{mono|^}}
| <code>^</code>
| {{mono|&}}
| <code>&</code>
| {{mono|ADFS::MyDrive.$.Documents.Letter}}<br>{{mono|Net#MainServer::DataDrive.$.Main.sy10823}}<br>{{mono|LanMan::WindowsC.$.Pictures.Japan/gif}}<br>{{mono|NFS:&.!Choices}}<br>{{mono|ADFS:%.IfThere}}<br>{{mono|@.inthisdir}}<br>{{mono|^.^.greatgrandparent}}{{efn|When filesystems with filename extensions are mounted, {{code|.}} characters are changed to {{code|/}}, as in the {{mono|Japan/gif}} example above}}
| <code>ADFS::MyDrive.$.Documents.Letter</code><br><code>Net#MainServer::DataDrive.$.Main.sy10823</code><br><code>LanMan::WindowsC.$.Pictures.Japan/gif</code><br><code>NFS:&.!Choices</code><br><code>ADFS:%.IfThere</code><br><code>@.inthisdir</code><br><code>^.^.greatgrandparent</code>
 
When filesystems with filename extensions are mounted,<br>'.' characters are changed to '/', as in the Japan/gif example above.
|-
|-
! [[Symbian OS]] File manager
! [[Symbian OS]] File manager
| <code>\</code>
| {{mono|\}}
| <code>\</code>
| {{mono|\}}
|  
|  
|  
|  
|
|
| <code>''\user\docs\Letter.txt''</code>
| {{mono|\user\docs\Letter.txt}}
|-
|-
! [[Domain/OS]] Shell
! [[Domain/OS]] Shell<ref>{{Cite book |title=Getting Started with Domain/OS |date=May 1988 |publisher=[[Apollo Computer]] |pages=7.1-7.7}}</ref>
|  
| {{mono|//}} (root of domain)<br>or {{mono|/}} (root of current node)
<span style="white-space:nowrap;"><code>//</code> (root of domain)</span><br>
| {{mono|/}}
<span style="white-space:nowrap;"><code>/</code> (root of current node)</span><br>
| {{mono|.}}
| <code>/</code>
| {{mono|\}}
| <code>.</code>
| {{mono|~}}
| <code>\</code>
| {{mono|//node/home/user/docs/Letter.txt}}<br>{{mono|./inthisdir}}<br>{{mono|\\greatgrandparent}}<br>{{mono|~rcinfo}}
| <code>~</code>
| <code>//node/home/user/docs/Letter.txt</code><br><code>./inthisdir</code><br><code>\\greatgrandparent</code><br><code>~rcinfo</code>
|-
|-
! [[MenuetOS]] CMD
! [[MenuetOS]] CMD
| <code>/</code>
| {{mono|/}}
| <code>/</code>
| {{mono|/}}
|  
|  
|  
|  
|
|
|
|{{Mono|/file}}
|-
|-
! [[Stratus VOS]] VOS command-line<br>interpreter
! [[Stratus VOS]] CLI
| <code>%''[system_name]''#''[module_name]''></code>
| {{mono|%[system_name]#[module_name]>}}
| <code>&gt;</code>
| {{mono|&gt;}}
|  
|  
| <code>&lt;</code>
| {{mono|&lt;}}
|  
|  
|<code>%sysname#module1>SubDir>AnotherDir</code>
|{{mono|%sysname#module1>SubDir>AnotherDir}}
|-
|-
! [[NonStop Kernel|NonStop<br>Kernel]] TACL<br>Tandem Advanced<br>Command&nbsp;Language
! [[NonStop Kernel|NonStop<br>Kernel]] TACL{{efn|Short for ''Tandem Advanced Command Language''}}
| No root
|
| <code>.</code>
| {{mono|.}}
|  
|  
| ''none''
|
|  
|  
| <code>\NODE.$DISK.SUBVOL.FILE</code><br><code>\NODE.$DEVICE</code><br><code>\NODE.$DEVICE.#SUBDEV.QUALIFIER</code>
| {{mono|\NODE.$DISK.SUBVOL.FILE}}<br>{{mono|\NODE.$DEVICE}}<br>{{mono|\NODE.$DEVICE.#SUBDEV.QUALIFIER}}
|-
|-
! [[CP/M]] [[Console Command Processor|CCP]]
! [[CP/M]] [[Console Command Processor|CCP]]<ref>{{Cite book |title=CP/M Operating System Manual |date=September 1983 |publisher=[[Digital Research]] |edition=3rd}}</ref>
| <code>''[drive letter:]''</code>
| {{mono|[drive letter:]}}
| colspan="4" | no directory support, just user areas 0–F
| colspan="4" |''no subdirectories, only user areas 0–F''
| align="left" | <code>A:LETTER.TXT</code>
|{{mono|A:LETTER.TXT}}
|-
|-
! [[Apple GS/OS|GS/OS]]
! [[Apple GS/OS|GS/OS]]
| <code>'':[volume name]:''</code> or <code>''.[device name]:''</code> or <code>''[prefix]:''</code>
| {{mono|:[volume name]:}}<br>or{{mono|.[device name]:}}<br>or {{mono|[prefix]:}}{{efn|{{code|[prefix]}} may be a number (0–31),  {{code|*}} (boot volume) or {{code|@}} (AppleShare home directory)}}
 
| {{mono|:}}<br>or {{mono|/}}
note: prefix may be a number (0–31), <code>*</code> (boot volume) or <code>@</code> (AppleShare home directory)
| <code>:</code><br>or<br><code>/</code>
|  
|  
|  
|  
| <code>@</code>
| {{mono|@}}
| <code>:Apps:Platinum.Paint:Platinum.Paint</code><br><code>*:System:Finder</code><br><code>.APPLEDISK3.5B/file</code>
| {{mono|:Apps:Platinum.Paint:Platinum.Paint}}<br>{{mono|*:System:Finder}}<br>{{mono|.APPLEDISK3.5B/file}}
|-
|-
![[OpenHarmony]] (incl. [[HarmonyOS]]) exec<ref>{{cite web |title=Introduction to the Shell |website=GitHub |publisher=OpenAtom OpenHarmony |url=https://github.com/eDorUS/OpenHarmony_docs/blob/master/en/device-dev/kernel/kernel-small-debug-shell-overview.md |access-date=13 March 2024}}</ref><ref>{{cite web |title=exec |website=GitHub |publisher=OpenAtom OpenHarmony |url=https://github.com/dashingcalico/OpenHarmony/blob/master/docs-en/kernel/exec.md |access-date=14 March 2024}}</ref>
![[OpenHarmony]] exec, Oniro, including [[HarmonyOS]]<ref>{{cite web |title=Introduction to the Shell |url=https://github.com/eDorUS/OpenHarmony_docs/blob/master/en/device-dev/kernel/kernel-small-debug-shell-overview.md |access-date=13 March 2024 |website=GitHub |publisher=OpenAtom OpenHarmony}}</ref><ref>{{cite web |title=exec |url=https://github.com/dashingcalico/OpenHarmony/blob/master/docs-en/kernel/exec.md |access-date=14 March 2024 |website=GitHub |publisher=OpenAtom OpenHarmony}}</ref>
|<code>hb set -root [ROOT_PATH]</code>
|{{mono|hb set -root [ROOT_PATH]}}<br>or {{mono|hb set -p --product [PRODUCT_NAME]}}
<code>hb set -p --product [PRODUCT_NAME]</code>
|{{mono|> or /}}
|<code>></code>
|{{mono|./}}
|<code>./</code>
|{{mono|../}}
|<code>../</code>
|
|
|<code>LOCAL>MEDIA_TYPE_>Download>Letter.txt</code>
|{{mono|LOCAL/MEDIA_TYPE_/Download/Letter.txt}}
|}
|}


Japanese and Korean versions of Windows often display the '[[¥]]' character or the '[[Won sign|₩]]' 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]] (other characters such as the square brackets were replaced as well, see [[ISO 646]], [https://www.microsoft.com/GLOBALDEV/Reference/dbcs/932.htm Windows Codepage 932 (Japanese Shift JIS)], and [https://www.microsoft.com/GLOBALDEV/Reference/dbcs/949.htm Codepage 949 (Korean)]). 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 backward compatibility.<ref>{{cite web |website=Sorting it all Out |title=When is a backslash not a backslash? |url=http://archives.miloush.net/michkap/archive/2005/09/17/469941.html}}</ref>
== In programming languages ==


[[macOS]], 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).
Most programming languages use the path representation of the underlying system, but some may also be system-independent.


==Paths in programming languages==
For instance, this C code is system-''dependent'' and may fail on opposing systems:
Programming languages also use paths. E.g.: When a file is opened. Most programming languages use the path representation of the underlying operating system:


  <code>uxFile = fopen("project/readme.txt", "r")</code>
<syntaxhighlight lang="c">uxFile = fopen("project/readme.txt", "r") // Fails on Windows
winFile = fopen("C:\\Program Files\\bin\\config.bat", "r") // Fails on Unix
</syntaxhighlight>


  <code>winFile = fopen("C:\\Program Files\\bin\\config.bat", "r")</code>
* In [[Java (programming language)|Java]], the {{var|File.separator}} field stores the system-dependent separator.<ref>{{Cite web |title=Java Development Kit Version 17 API Specification |url=https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/File.html#separator |access-date=2025-09-07 |website=docs.oracle.com |language=en}}</ref> Some functions preclude the need for the separator entirely.
:<syntaxhighlight lang="java">import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
// ...
File file = new File("path" + File.separator + "file.txt");
Path path = Paths.get("path", "file.txt");
</syntaxhighlight>
* In [[Python (programming language)|Python]], the {{code|pathlib}} module offers system-independent path operations.<ref>{{Cite web |title=os.path — Common pathname manipulations |url=https://docs.python.org/3/library/os.path.html |access-date=2025-09-07 |website=Python documentation |language=en}}</ref>
:<syntaxhighlight lang="python">from pathlib import Path


This direct access to the operating system paths can hinder the portability of programs. To support portable programs [[Java (programming language)|Java]] uses ''File.separator'' to distinguish between / and \ separated paths. [[Seed7]] 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'').
with (Path("path") / "to" / "file.txt").open() as open_file:
 
    ...
==Universal Naming Convention==
</syntaxhighlight>
{{Anchor|UNC}}
The Microsoft '''universal naming convention''' ('''UNC'''), a.k.a. '''uniform naming convention''', a.k.a. '''network path''', specifies a syntax to describe the location of a network resource, such as a shared file, directory, or printer. A UNC path has the general form:


\\ComputerName\SharedFolder\Resource
== In Unix ==
Most Unix-like systems use a similar syntax.<ref>{{cite web |title=UNC Definition |url=https://www.computerlanguage.com/results.php?definition=UNC |website=ComputerLanguage.com}}</ref> [[POSIX]] allows treating a path beginning with two slashes in an implementation-defined manner,<ref>{{cite web |title=POSIX pathname resolution specification |url=https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11}}</ref> though in other cases systems must treat consecutive slashes as one.<ref>{{cite web |title=POSIX pathname definition |url=http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_266}}</ref>


Some Windows interfaces allow or require UNC syntax for [[WebDAV]] share access, rather than a URL. The UNC syntax is extended<ref>{{cite web |title=DavGetHTTPFromUNCPath function |department=WebDAV: Windows |website=[[Microsoft Docs]] |series=series |date=13 October 2021 |url=https://learn.microsoft.com/windows/win32/api/davclnt/nf-davclnt-davgethttpfromuncpath |access-date=2023-10-04}}</ref> with optional components to denote use of SSL and TCP/IP port number, a WebDAV URL of <code>http[s]://HostName[:Port]/SharedFolder/Resource</code> becomes
Many applications on Unix-like systems (for example, [[secure copy|scp]], [[rcp (Unix)|rcp]], and [[rsync]]) use resource definitions such as {{code|hostname:/directorypath/resource}}, or [[list of URI schemes|URI]] schemes with the service name (here '[[Server Message Block|smb]]'), like {{code|smb://hostname/directorypath/resource}}.


\\HostName[@SSL][@Port]\SharedFolder\Resource
=== In macOS ===
When [[macOS]] was being developed, it inherited some pathname choices from [[Classic Mac OS]] and the [[Unix-like]] [[NeXTSTEP]]. The classic Mac OS uses a {{Code|:}} while [[Unix]] and Unix-like systems use a {{Code|/}} as the path delimiter. As a solution, to preserve compatibility for software and familiarity for users, and to allow disk file systems to be used both by the classic Mac OS and macOS, some portions of macOS convert between colons and slashes in pathnames;<ref>{{Cite web |last=Chan |first=Alex |date=2021-12-01 |title=A tale of two path separators |url=https://alexwlchan.net/2021/slashes/ |access-date=2025-09-07 |website=alexwlchan.net |language=en}}</ref> for example, the HFS+ file system, from the classic Mac OS, converts colons in file names to slashes and, when reading a directory, converts slashes in filenames to colons,<ref name="sanchez-usenix">{{cite web |url=https://www.wsanchez.net/papers/USENIX_2000/ |title=The Challenges of Integrating the Unix and Mac OS Environments |first=Wilfredo |last=Sanches |date=2000}}</ref> as and the [[Carbon (API)|Carbon]] toolkit converts colons in pathnames to slashes and slashes in path names to colons, and converts them back when providing filenames and pathnames to the caller.<ref name="sanchez-usenix" />


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".
== In DOS and Windows ==
[[File:Dir command in Windows Command Prompt.png|thumb|300px|Screenshot of a [[Microsoft Windows|Windows]] [[Command Prompt]] shell showing filenames in a directory]]{{See also|8.3 filename}}
DOS and Windows have no single root directory; a root exists for each storage drive, indicated with a drive letter or through UNC.


Some Windows interfaces also accept the "Long UNC":
Directory and file name comparisons are case-insensitive: "test.TXT" would match "Test.txt".<ref name="netpaths" />


\\?\UNC\ComputerName\SharedFolder\Resource
Windows understands the following kinds of paths:
* Local paths, such as {{code|C:\File}}.
* [[Path (computing)#Universal Naming Convention|Universal naming convention (UNC)]].
* DOS device paths, such as {{code|\\?\C:\File}} or {{code|\\.\UNC\Server\Volume\File}}. The first, {{Code|\\?\}} skips path normalization. The second, {{code|\\.\}} uses the raw device namespace.<ref name="netpaths">{{cite web |last=De George |first=Andy |date=2022-12-14 |title=File path formats on Windows systems |url=https://learn.microsoft.com/dotnet/standard/io/file-path-formats |access-date=2019-07-14 |website=[[Microsoft Docs]] |department=}}</ref><ref name="w32paths">{{cite web |last=Ashcraft |first=Alvin |date=2024-08-28 |title=Naming Files, Paths, and Namespaces |url=https://learn.microsoft.com/windows/win32/fileio/naming-a-file |website=[[Microsoft Docs]]}}</ref>


Windows uses the following types of paths:
In the [[Windows API]], file I/O functions automatically convert {{code|/}} into {{code|\}} (except when using the {{code|\\?\}} prefix). Unless the {{Code|\\?\}} prefix is used, paths are limited to the length defined by {{Var|MAX_PATH}}. This variable defaulted to 260 characters until Windows 10, when it could be expanded to 32,767.<ref>{{Cite web |last=Ashcraft |first=Alvin |date=2024-07-16 |title=Maximum Path Length Limitation - Win32 apps |url=https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation |access-date=2025-09-07 |website=learn.microsoft.com |language=en-us}}</ref>


* local file system (LFS), such as <code>C:\File</code>
[[PowerShell]] allows slash-interoperability for backwards-compatibility:<ref>{{Cite web |last=Wheeler |first=Sean |title=about_Path_Syntax - PowerShell |url=https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_path_syntax?view=powershell-7.5 |access-date=2025-09-07 |website=learn.microsoft.com |language=en-us}}</ref>
* universal naming convention (UNC), such as <code>\\Server\Volume\File</code> or /<code><internet resource name>[\Directory name]</code> (at least in Windows 7 and later)
* "long" device path such as <code>\\?\C:\File</code> or <code>\\?\UNC\Server\Volume\File</code>.<ref name="netpaths">{{cite web |title=File path formats on Windows systems |department=File and Stream I/O: .NET |website=[[Microsoft Docs]] |url=https://learn.microsoft.com/dotnet/standard/io/file-path-formats |access-date=2019-07-14}}</ref> This path points to the local file namespace and {{code|\\.\}} 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 {{mono|/}} to {{mono|\}} and interpreting names like {{mono|..}}.<ref name="w32paths" />
* [[Object Manager (Windows)|Windows NT object manager]] <code>\\??\</code>-prefixed paths (global DOS namespace).<ref>{{cite web |title=winapi - Is there a difference between \??\ and \\?\ paths? |website=Stack Overflow |url=https://stackoverflow.com/questions/25090101/is-there-a-difference-between-and-paths}}</ref><ref>{{cite web |title=Path prefixes \??\ and \\?\ |website=Stack Overflow |url=https://stackoverflow.com/a/46019856}}</ref>


In versions of Windows prior to Windows XP, only the APIs that accept "long" device paths could accept more than 260 characters.
<syntaxhighlight lang="powershell">PS C:\>Get-Content -Path "C:/path/to/file.txt"


The [[Windows shell|shell]] in [[Windows XP]] and [[Windows Vista]], [[explorer.exe]], allows path names up to 248 characters long.{{citation needed|date=February 2014}}
Here is some text within a file</syntaxhighlight>


Since UNCs start with two backslashes, and the backslash is also used for string escaping and in [[regular expression]]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 – <code>\\\\\\\\</code> – because the string and regular expression both require escaping. This can be simplified by using [[raw string]]s, as in C#'s <code>@"\\\\"</code> or Python's <code>r'\\\\'</code>, or regular expression literals, as in Perl's <code>qr{\\\\}</code>.
=== Yen/won character error ===
{{Main|Backslash#Confusion with ¥ and other characters}}


==POSIX pathname definition==
Japanese and Korean versions of Windows often displayed the '[[¥]]' character or the '[[Won sign|₩]]' character instead of the directory separator. This is because while in ANSI codepages, the character at 0x5C was the backslash, and in Japanese and Korean codepages, 0x5C was the yen and won signs, respectively. Therefore, when the character for a backslash was used, other glyphs appeared.<ref>{{cite web |title=When is a backslash not a backslash? |url=http://archives.miloush.net/michkap/archive/2005/09/17/469941.html |website=Sorting it all Out}}</ref>
Most Unix-like systems use a similar syntax.<ref>{{cite web |title=UNC Definition |website=ComputerLanguage.com |url=https://www.computerlanguage.com/results.php?definition=UNC}}</ref>
[[POSIX]] allows treating a path beginning with two slashes in an implementation-defined manner,<ref>{{cite web |title=POSIX pathname resolution specification |url=https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11}}</ref>
though in other cases systems must treat multiple slashes as single slashes.<ref>{{cite web |title=POSIX pathname definition |url=http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_266}}</ref>
Many applications on Unix-like systems (for example, [[secure copy|scp]], [[rcp (Unix)|rcp]], and [[rsync]]) use resource definitions such as:


hostname:/directorypath/resource
=== Universal Naming Convention ===
 
{{Anchor|UNC}}
or [[list of URI schemes|URI]] schemes with the service name (here 'smb'):
 
smb://hostname/directorypath/resource
 
==Examples==


===Unix===
The Microsoft '''Universal Naming Convention''' ('''UNC''', '''uniform naming convention''', or '''network path'''), is a syntax to describe the location of a network resource, such as a shared file, directory, or printer. A UNC path has the general form:
The following examples are for typical, Unix-based file systems:


Given the working directory is {{code|/home/mark/}} and it contains subdirectory {{code|bobapples}}, relative paths to the subdirectory include {{code|./bobapples}} and {{code|bobapples}}, and the absolute path is {{code|/home/mark/bobapples}}. A command to change the working directory to the subdirectory:
{{Mono|\\ComputerName\SharedFolder\Resource}}


<syntaxhighlight lang="console>
Some Windows interfaces allow or require UNC syntax for [[WebDAV]] share access, rather than a URL. The UNC syntax is extended with optional components to denote use of SSL and TCP/IP port number. Thus, the WebDAV URL of {{code|https://hostname:443/SharedFolder/Resource}} becomes {{code|\\hostname@SSL@443\SharedFolder\Resource}}.<ref>{{cite web |date=13 October 2021 |title=DavGetHTTPFromUNCPath function |url=https://learn.microsoft.com/windows/win32/api/davclnt/nf-davclnt-davgethttpfromuncpath |access-date=2023-10-04 |website=[[Microsoft Docs]] |series=series |department=WebDAV: Windows}}</ref>
$ cd bobapples
</syntaxhighlight>


If the working directory was {{code|/home/jo}}, then the relative path {{code|../mark/bobapples}} specifies the subdirectory. The double dots {{code|..}} indicates a move up the directory hierarchy one level to {{code|/home}}, the rest indicates moving down to {{code|mark}} and then {{code|boapples}}.
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 during creation of the share.


===Microsoft shells===
Since UNCs start with two backslashes, and the backslash is also used for [[Escape sequence|escape sequences]] and in [[regular expression]]s, cases of [[leaning toothpick syndrome]] may arise. An escaped string for a regular expression matching a UNC begins with 8 backslashes {{code|\\\\\\\\}} because the string and regular expression both require escaping. This can be simplified by using [[raw string]]s, such as {{code|@"\\\\"|csharp}} in C#, {{code|r'\\\\'|python}} in [[Python (programming language)|Python]], or {{code|qr{\\\\}|perl}} in [[Perl]].
{{More citations needed section|date=November 2020}}


[[File:Dir command in Windows Command Prompt.png|thumb|300px|Screenshot of a [[Microsoft Windows|Windows]] [[Command Prompt]] shell showing filenames in a directory]]
== See also ==
 
<!--Contrary to popular belief, -->
The [[Windows API]] accepts slash for path delimiter.
 
Unlike Unix that always has a single root directory, a Windows file system has a root for each storage drive. An absolute path includes a drive letter or uses the UNC format.
 
A UNC path (starting with {{code|\\?\}}) does not support slashes.<ref name="w32paths" />
 
<code>A:\Temp\File.txt</code> is an absolute path that specifies a file named {{code|File.txt}} in the directory {{code|Temp}} which is in the root of drive {{code|A:}}:
 
<code>C:..\File.txt</code> is a relative path that specifies file {{code|File.txt}} located in the parent of the working directory on drive {{code|C:}}:
 
<code>Folder\SubFolder\File.txt</code> is a relative path that specifies file {{code|File.txt}} in directory {{code|SubFolder}} which is in directory {{code|Folder}} which is in the working directory of the current drive:
 
<code>File.txt</code> is a relative path that specifies <code>File.txt</code> in the working directory:
 
<code>\\.\COM1</code> specifies the first [[serial port]], [[COM (hardware interface)|COM1]]:
 
The following uses a path with slashes for directory delimiter:
 
<syntaxhighlight lang="doscon">
C:\>more < C:/Windows/system.ini
; for 16-bit app support
[386Enh]
woafont=dosapp.fon
EGA80WOA.FON=EGA80WOA.FON
EGA40WOA.FON=EGA40WOA.FON
CGA80WOA.FON=CGA80WOA.FON
CGA40WOA.FON=CGA40WOA.FON
...
</syntaxhighlight>
 
A path with forward slashes may need to be surrounded by double quotes to disambiguate from command-line switches. For example, {{code|dir /windows}} is invalid, but {{code|dir "/window"}} is valid. And {{code|cd}} is more lenient by allowing {{code|cd /windows}}.
 
==See also==


* {{Annotated link|basename}}
* {{Annotated link|basename}}
Line 326: Line 274:
* {{Annotated link|URL}}
* {{Annotated link|URL}}


==References==
== Notes ==
{{Notelist}}
 
== References ==
{{Reflist}}
{{Reflist}}
==External links==
* [https://www.linfo.org/path.html Path Definition] - The Linux Information Project (LINFO)
* [https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file Naming Files, Paths, and Namespaces] - Local File Systems: Windows: [[Microsoft Docs]]


{{Computer files}}
{{Computer files}}


[[Category:Computer file systems]]
[[Category:Computer file systems]]

Latest revision as of 13:00, 20 December 2025

Template:Short description Template:Use dmy dates Script error: No such module "For".

A path (or filepath, file path, pathname, or similar) is a string that uniquely identifies an item in a hierarchical file system. Generally, a path is composed of directory names, special format specifiers, and optionally a filename, all separated by delimiters. This delimiter can vary by operating system, but popular, modern systems use the slash /, backslash \, or colon :.

The case-sensitivity of individual path components will vary based on operating system, or based on options specified at the time of a file system's creation or first use. In practice, this means that for a case-sensitive system, path components named component1 and Component1 can coexist at the same level in the hierarchy, whereas for a case-insensitive file system, they cannot (an error will occur). macOS and Windows' native file systems are case-insensitive by default, whereas typical Linux file systems are case-sensitive.[1][2][3]

Script error: No such module "anchor".Script error: No such module "anchor".A path can be either relative or absolute. A relative path is a path in relation to another, most often the working directory. An absolute path indicates a location regardless of the current directory; that is, it specifies all path components starting from the file system's root, and does not depend on context like a relative path does.

Paths are also essential for locating hierarchically-organized network resources, as seen in URLs and UNC paths.

History

Multics first introduced a hierarchical file system with directories (separated by ">") in the mid-1960s.[4]

Around 1970, Unix introduced the slash / as its directory separator.

Originally, MS-DOS did not support directories. When adding the feature, using the Unix standard of a slash was not a good option since many existing commands used a slash as the switch prefix (i.e., dir /w). In contrast, Unix uses the dash - as the switch prefix. The backslash \ was ultimately chosen instead for its similarity to the slash and not conflicting with existing commands. This convention continued into Windows. However, some areas of Windows do accept or understand Unix-style slashes also, such as PowerShell.[5][6]

Summary of systems

The following table describes the syntax of paths in notable operating systems:Template:Table alignment

System Root dir. Path delim. Working dir. Parent dir. Home dir. Examples
Unix and Unix-like systems, including macOS[7] Template:Mono Template:Mono Template:Mono Template:Mono Template:Mono Template:Mono
Template:Mono
Template:Mono
Template:Mono
Windows, Command Prompt Template:Mono (relative to current working directory root)
or Template:Mono
or Template:Mono
or Template:Mono
or UNC
Template:MonoTemplate:Efn
or Template:Mono
Template:Mono Template:Mono Template:Mono
Template:MonoTemplate:Mono

Template:Mono
Template:Mono
Template:Mono

PowerShell Template:Mono
or Template:Mono
or Template:Mono
or UNC
Template:MonoTemplate:Efn
or Template:Mono
Template:Mono Template:Mono Template:Mono Template:Mono
Template:MonoTemplate:Mono
Template:Mono
Template:Mono
Template:Mono
UNC[8] Template:Mono Template:Mono Template:Mono
DOS, COMMAND.COM Template:Mono
or Template:Mono
Template:Mono Template:Mono Template:Mono Template:Mono
Template:Mono
Template:Mono
OS/2 Template:Mono
or Template:Mono
Template:Mono
or Template:Mono
Template:Mono Template:Mono Template:Mono
Template:Mono
Template:Mono
RSX-11 MCR[9] Template:Mono Template:MonoTemplate:Efn
TOPS-20 DCL[10] Template:Mono Template:Mono Template:Mono
OpenVMS DCL[11][12] Template:Mono
or Template:Mono
Template:Mono Template:Mono Template:Mono Template:Mono Template:MonoTemplate:MonoTemplate:Mono
Template:Mono
Template:Mono
Template:Mono
Template:Mono
ProDOS AppleSoft BASIC[13] Template:Mono Template:Mono Template:MonoTemplate:Mono
AmigaOS Amiga CLI / AmigaShell[14] Template:Mono Template:Mono empty string Template:Mono Template:Mono
Template:Mono
Template:Mono
Template:Mono
RISC OS ShellCLI[15] Template:MonoTemplate:Efn Template:Mono Template:Mono Template:Mono Template:Mono Template:Mono
Template:Mono
Template:Mono
Template:Mono
Template:Mono
Template:Mono
Template:MonoTemplate:Efn
Symbian OS File manager Template:Mono Template:Mono Template:Mono
Domain/OS Shell[16] Template:Mono (root of domain)
or Template:Mono (root of current node)
Template:Mono Template:Mono Template:Mono Template:Mono Template:Mono
Template:Mono
Template:Mono
Template:Mono
MenuetOS CMD Template:Mono Template:Mono Template:Mono
Stratus VOS CLI Template:Mono Template:Mono Template:Mono Template:Mono
NonStop
Kernel
TACLTemplate:Efn
Template:Mono Template:Mono
Template:Mono
Template:Mono
CP/M CCP[17] Template:Mono no subdirectories, only user areas 0–F Template:Mono
GS/OS Template:Mono
orTemplate:Mono
or Template:MonoTemplate:Efn
Template:Mono
or Template:Mono
Template:Mono Template:Mono
Template:Mono
Template:Mono
OpenHarmony exec, Oniro, including HarmonyOS[18][19] Template:Mono
or Template:Mono
Template:Mono Template:Mono Template:Mono Template:Mono

In programming languages

Most programming languages use the path representation of the underlying system, but some may also be system-independent.

For instance, this C code is system-dependent and may fail on opposing systems:

uxFile = fopen("project/readme.txt", "r") // Fails on Windows
winFile = fopen("C:\\Program Files\\bin\\config.bat", "r") // Fails on Unix
  • In Java, the Template:Var field stores the system-dependent separator.[20] Some functions preclude the need for the separator entirely.
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
// ...
File file = new File("path" + File.separator + "file.txt");
Path path = Paths.get("path", "file.txt");
  • In Python, the pathlib module offers system-independent path operations.[21]
from pathlib import Path

with (Path("path") / "to" / "file.txt").open() as open_file:
    ...

In Unix

Most Unix-like systems use a similar syntax.[22] POSIX allows treating a path beginning with two slashes in an implementation-defined manner,[23] though in other cases systems must treat consecutive slashes as one.[24]

Many applications on Unix-like systems (for example, scp, rcp, and rsync) use resource definitions such as hostname:/directorypath/resource, or URI schemes with the service name (here 'smb'), like smb://hostname/directorypath/resource.

In macOS

When macOS was being developed, it inherited some pathname choices from Classic Mac OS and the Unix-like NeXTSTEP. The classic Mac OS uses a : while Unix and Unix-like systems use a / as the path delimiter. As a solution, to preserve compatibility for software and familiarity for users, and to allow disk file systems to be used both by the classic Mac OS and macOS, some portions of macOS convert between colons and slashes in pathnames;[25] for example, the HFS+ file system, from the classic Mac OS, converts colons in file names to slashes and, when reading a directory, converts slashes in filenames to colons,[26] as and the Carbon toolkit converts colons in pathnames to slashes and slashes in path names to colons, and converts them back when providing filenames and pathnames to the caller.[26]

In DOS and Windows

File:Dir command in Windows Command Prompt.png
Screenshot of a Windows Command Prompt shell showing filenames in a directory

Script error: No such module "Labelled list hatnote".

DOS and Windows have no single root directory; a root exists for each storage drive, indicated with a drive letter or through UNC.

Directory and file name comparisons are case-insensitive: "test.TXT" would match "Test.txt".[27]

Windows understands the following kinds of paths:

  • Local paths, such as C:\File.
  • Universal naming convention (UNC).
  • DOS device paths, such as \\?\C:\File or \\.\UNC\Server\Volume\File. The first, \\?\ skips path normalization. The second, \\.\ uses the raw device namespace.[27][28]

In the Windows API, file I/O functions automatically convert / into \ (except when using the \\?\ prefix). Unless the \\?\ prefix is used, paths are limited to the length defined by Template:Var. This variable defaulted to 260 characters until Windows 10, when it could be expanded to 32,767.[29]

PowerShell allows slash-interoperability for backwards-compatibility:[30]

PS C:\>Get-Content -Path "C:/path/to/file.txt"

Here is some text within a file

Yen/won character error

Script error: No such module "Labelled list hatnote".

Japanese and Korean versions of Windows often displayed the '¥' character or the '' character instead of the directory separator. This is because while in ANSI codepages, the character at 0x5C was the backslash, and in Japanese and Korean codepages, 0x5C was the yen and won signs, respectively. Therefore, when the character for a backslash was used, other glyphs appeared.[31]

Universal Naming Convention

Script error: No such module "anchor".

The Microsoft Universal Naming Convention (UNC, uniform naming convention, or network path), is a syntax to describe the location of a network resource, such as a shared file, directory, or printer. A UNC path has the general form:

Template:Mono

Some Windows interfaces allow or require UNC syntax for WebDAV share access, rather than a URL. The UNC syntax is extended with optional components to denote use of SSL and TCP/IP port number. Thus, the WebDAV URL of https://hostname:443/SharedFolder/Resource becomes \\hostname@SSL@443\SharedFolder\Resource.[32]

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 during creation of the share.

Since UNCs start with two backslashes, and the backslash is also used for escape sequences and in regular expressions, cases of leaning toothpick syndrome may arise. 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 strings, such as @"\\\\" in C#, r'\\\\' in Python, or qr{\\\\} in Perl.

See also

Notes

Template:Notelist

References

<templatestyles src="Reflist/styles.css" />

  1. Script error: No such module "citation/CS1". Includes a description of APFS, the default file system for macOS
  2. Script error: No such module "citation/CS1". Windows file system treats file and directory names as case-insensitive. FOO.txt and foo.txt will be treated as equivalent files. Linux file system treats file and directory names as case-sensitive. FOO.txt and foo.txt will be treated as distinct files.
  3. Script error: No such module "citation/CS1". Case sensitivity in Linux refers to files and directories recognizing differences between lowercase and uppercase characters in filenames. For instance, "File.txt" and "file.txt" would both be treated as two distinct files. This concept is integral to Unix-like operating systems, including Linux.
  4. Script error: No such module "citation/CS1".
  5. Script error: No such module "citation/CS1".
  6. Script error: No such module "citation/CS1".
  7. Script error: No such module "citation/CS1".
  8. Script error: No such module "citation/CS1".
  9. Script error: No such module "citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "citation/CS1".
  12. Script error: No such module "citation/CS1".
  13. Script error: No such module "citation/CS1".
  14. Script error: No such module "citation/CS1".
  15. Script error: No such module "citation/CS1".
  16. Script error: No such module "citation/CS1".
  17. Script error: No such module "citation/CS1".
  18. Script error: No such module "citation/CS1".
  19. Script error: No such module "citation/CS1".
  20. Script error: No such module "citation/CS1".
  21. Script error: No such module "citation/CS1".
  22. Script error: No such module "citation/CS1".
  23. Script error: No such module "citation/CS1".
  24. Script error: No such module "citation/CS1".
  25. Script error: No such module "citation/CS1".
  26. a b Script error: No such module "citation/CS1".
  27. a b Script error: No such module "citation/CS1".
  28. Script error: No such module "citation/CS1".
  29. Script error: No such module "citation/CS1".
  30. Script error: No such module "citation/CS1".
  31. Script error: No such module "citation/CS1".
  32. Script error: No such module "citation/CS1".

Script error: No such module "Check for unknown parameters".

Template:Computer files