This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Module : filepath

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.

Records

Detail

A record type defined to be used as the "error detail" in the errors defined in this module.

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.

filename

Retrieves the base name of the file from the provided location, which is the last element of the path.

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.

isReservedName

Reports whether the filename is reserved.

matches

Reports whether the complete filename (not just a substring of it) matches the provided Glob pattern.

normalize

Returns the shortest path name equivalent to the given path.

parent

Returns the enclosing parent directory.

relative

Returns a relative path, which is logically equivalent to the target path when joined to the base path with an intervening separator.

resolve

Returns the filepath after the evaluation of any symbolic links.

split

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

Constants

FILE_NOT_FOUND_ERROR

Identifies file not found error.

Identifies no link error.

IO_ERROR

Identifies io error.

SECURITY_ERROR

Identifies security error.

INVALID_PATH_ERROR

Identifies invalid path error.

INVALID_PATTERN_ERROR

Identifies invalid pattern error.

RELATIVE_PATH_ERROR

Identifies relative path error.

UNC_PATH_ERROR

Identifies unc path error.

GENERIC_ERROR

Identifies generic error.

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.