File System - Path

1 - About

A file is identified by its path through the file system.

See also hierarchical URI where:

  • The scheme represents the file system
  • The authority represents the connection information
  • The path represents the file system path.

3 - Operating System

Os Root Node Directory Delimiter
in the
path
Path Delimiter
in the
Environment Variable
Windows maps to a volume, such as C:\ or D:\ back slashes semicolon (;)
Unix/Linux A single root node is supported, which is denoted by the slash character, /. forward slashes colon

Example:

  • Unix
/directory1a/directory1b/directory1c/myFile.extension:/directory2a/directory2b/directory3c/myFile
  • Windows
C:\directory1a\directory1b\directory1c\myFile.extension:D:\directory2a\directory2b\directory3c\myFile

Relative file paths are much more portable.

Note:

  • DOS descended file systems are case insensitive
  • Windows pretends that all file extensions with four or more letters are also three letter extensions (try DELETE *.jav in your java directories to see a disastrous example of this).

4 - Delimiter

The character used to separate the directory names (also called the delimiter) is specific to the file system.

Unix paths use forward slashes between directories.

5 - Form

5.1 - Relative or Absolute

A path is either relative or absolute.

5.1.1 - absolute

An absolute path always contains the root element and the complete directory list required to locate the file.

Example of an absolute path

/home/gerardnico/readme

All of the information needed to locate the file is contained in the path string.

5.1.2 - relative

A relative path needs to be combined with another path (very often with the current path) in order to access a file. Relative file paths are much more portable.

Example of a relative path.

joe/foo 

5.2 - Abstract

An abstract pathname has two components:

  • An optional system-dependent prefix string
  • A sequence of zero or more string names.

The first name in an abstract pathname may be:

  • a directory name
  • or a hostname (in the case of Microsoft Windows UNC pathnames),

Each subsequent name in an abstract pathname denotes a directory; the last name may denote either a directory or a file.

A pathname, whether abstract or in string form, may be either absolute or relative.

5.3 - Canonical

The canonical path is both an absolute and unique representation of a file in a file system.

The precise definition of canonical form is system-dependent.

A canonical method first converts the pathname to absolute form if necessary and then maps it to its unique form in a system-dependent way. This typically involves:

  • removing redundant names such as “.” and “..” from the pathname,
  • resolving symbolic links (on UNIX platforms),
  • and converting drive letters to a standard case (on Microsoft Windows platforms).

6 - Prefix

The prefix concept is used to handle:

  • root directories on UNIX platforms,

For UNIX platforms, the prefix of an absolute pathname is always “/”. Relative pathnames have no prefix. The abstract pathname denoting the root directory has the prefix “/” and an empty name sequence.

  • and drive specifiers, root directories and UNC pathnames on Microsoft Windows platforms

For Microsoft Windows platforms, the prefix of a pathname that contains a drive specifier consists of the drive letter followed by “:” and possibly followed by “\\” if the pathname is absolute. The prefix of a UNC pathname is “\\\\”; the hostname and the share name are the first two names in the name sequence. A relative pathname that does not specify a drive has no prefix.

Prefix can then be:

  • a disk-drive specifier (C:\),
  • “/” for a UNIX root directory,
  • or “\\\\” for a Microsoft Windows UNC pathname

7 - Parsing

7.1 - Oracle

The second element of a path. See Oracle Database - SQL - Regular expression

REGEXP_REPLACE(path, '(/[^/]+)/([^/]+)(.*)','\2') 

8 - Documentation / Reference

file/path.txt · Last modified: 2017/10/08 12:43 by gerardnico