Functions - filepath

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 path. it is empty if there is no dot.

filename

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

getPathListSeparator

Returns path list separator of underline operating system.

getPathSeparator

Returns path separator of underline 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 is absolute

isReservedName

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

matches

Reports whether all of filename matches the provided pattern, not just a substring. An error is returned if the pattern is malformed.

normalize

Returns the shortest path name equivalent to path by purely lexical processing. Replace 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 that is logically equivalent to target path when joined to base path with an intervening separator. An error is returned if target path can't be made relative to base path.

resolve

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

split

Splits a list of paths joined by the OS-specific Path Separator.

absolute

(string path)

returns string | error

Retrieves the absolute path from the provided location.

Parameters

  • path string
  • String value of file path.

  • Return Type

    (string | error)
  • The absolute path reference or an error if the path cannot be derived

build

(string[] parts)

returns string | error

Joins any number of path elements into a single path

Parameters

  • parts string[]
  • String values of file path parts.

  • Return Type

    (string | error)
  • String value of file path.

extension

(string path)

returns string | error

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

Parameters

  • path string
  • String value of file path.

  • Return Type

    (string | error)
  • Returns the extension of the file. Empty string if no extension.

filename

(string path)

returns string | error

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

Parameters

  • path string
  • String value of file path.

  • Return Type

    (string | error)
  • Returns the name of the file

getPathListSeparator

()

returns string

Returns path list separator of underline operating system.

  • Return Type

    (string)
  • String value of path list separator

getPathSeparator

()

returns string

Returns path separator of underline operating system.

  • Return Type

    (string)
  • String value of path separator

isAbsolute

(string path)

returns boolean | error

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 is absolute

Parameters

  • path string
  • String value of file path.

  • Return Type

    (boolean | error)
  • True if path is absolute, else false

isReservedName

(string name)

returns boolean

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

Parameters

  • Return Type

    (boolean)
  • true, if path is Windows reserved name.

matches

(string path, string pattern)

returns boolean | error

Reports whether all of filename matches the provided pattern, not just a substring. An error is returned if the pattern is malformed.

Parameters

  • path string
  • String value of the file path.

  • pattern string
  • String value of the target file path.

  • Return Type

    (boolean | error)
  • True if filename of the path matches with the pattern, else false

normalize

(string path)

returns string | error

Returns the shortest path name equivalent to path by purely lexical processing. Replace multiple Separator elements with a single one. Eliminate each . path name element (the current directory). Eliminate each inner .. path name element (the parent directory)

Parameters

  • path string
  • String value of file path.

parent

(string path)

returns string | error

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.

Parameters

  • path string
  • String value of file path.

  • Return Type

    (string | error)
  • Path of parent folder or error occurred while getting parent directory

relative

(string base, string target)

returns string | error

Returns a relative path that is logically equivalent to target path when joined to base path with an intervening separator. An error is returned if target path can't be made relative to base path.

Parameters

  • base string
  • String value of the base file path.

  • target string
  • String value of the target file path.

  • Return Type

    (string | error)
  • Returns the extension of the file. Empty string if no extension.

resolve

(string path)

returns string | error

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

Parameters

  • path string
  • String value of file path.

split

(string path)

returns string[] | error

Splits a list of paths joined by the OS-specific Path Separator.

Parameters

  • path string
  • String value of file path.

  • Return Type

    (string[] | error)
  • String array of part components