Module : filepath

Version : 0.7.0

Module Overview

This module provides a platform-independent API for working with file paths.

For information on the operations, which you can perform with this module, see the below Functions.

Functions

absolute

Retrieves the absolute path from the provided location.

build

Joins any number of path elements into a single path.

extension

Retrieves the extension of the file path. The extension is the suffix beginning at the final dot in the final element of the path. It is empty if there is no dot.

filename

Retrieves the base name of the file from the provided location, which is the last element of the path. Trailing path separators are removed before extracting the last element.

getPathListSeparator

Returns the path variable's separating character for paths of the underlying operating system.

getPathSeparator

Returns the path separator of the underlying operating system.

isAbsolute

Reports whether the path is absolute. A path is absolute if it is independent of the current directory. On Unix, a path is absolute if it starts with the root. On Windows, a path is absolute if it has a prefix and starts with the root: c:\windows.

isReservedName

Reports whether the filename is reserved. Reserved words only exist in Windows.

matches

Reports whether the complete filename (not just a substring of it) matches the provided Glob pattern. An error is returned if the pattern is malformed.

normalize

Returns the shortest path name equivalent to the given path. Replace the multiple separator elements with a single one. Eliminate each "." path name element (the current directory). Eliminate each inner ".." path name element (the parent directory).

parent

Returns the enclosing parent directory. If the path is empty, parent returns ".". The returned path does not end in a separator unless it is the root directory.

relative

Returns a relative path, which is logically equivalent to the target path when joined to the base path with an intervening separator. An error is returned if the target path cannot be made relative to the base path.

resolve

Returns the filepath after the evaluation of any symbolic links. If the path is relative, the result will be relative to the current directory unless one of the components is an absolute symbolic link. Resolves normalising the calls on the result.

split

Splits a list of paths joined by the OS-specific path separator.

Types

Error

Represents filepath related errors.

Errors

FileNotFoundError

Represents error occur when the file/directory does not exist at the given filepath.

GenericError

Represents generic error for filepath

IOError

Represents IO error occur when trying to access the file at the given filepath.

InvalidPathError

Represents error occur when the given file path is invalid.

InvalidPatternError

Represent error occur when the given pattern is not a valid filepath pattern.

NotLinkError

Represents error occur when the file at the given filepath is not a symbolic link.

RelativePathError

Represents an error that occurs when the given target filepath cannot be derived relative to the base filepath.

SecurityError

Represents security error occur when trying to access the file at the given filepath.

UNCPathError

Represents error occur in the UNC path.