Path (computing)
A path (or filepath, file path, pathname, or similar) is a string that uniquely identifies an item in a hierarchical file system.
≈ 3 min read
Path (computing). encyclopegia.org, snapshot enwiki-001378833930. /a/path-computing
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
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 and 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.
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. uxFile = fopen("project/readme.txt", "r") // Fails on Windows winFile = fopen("C:\\Program Files\\bin\\config.bat", "r") // Fails on Unix In Java, the field stores the system-dependent separator. 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 module offers system-independent path operations. from pathlib import Path with (Path("path") / "to" / "file.txt").open() as open_file: ... PS C:\>Get-Content -Path "C:/path/to/file.txt" Here is some text within a file
Text derived from https://en.wikipedia.org/w/index.php?oldid=1378833930 under CC BY-SA 4.0; modifications have been made.