Functions - system

copy

Copy file/directory in old path to new path. If new path already exists, this replaces the file.

createDir

Creates a new directory with the specified file name. If parentDirs flag is true, Creates a directory in specified path with any necessary parents.

createFile

Creates a file in specified file path. Truncates if file already exists in the given path.

exists

Reports whether file or directory exists for the given the path.

getCurrentDirectory

Returns the current working directory.

getEnv

Returns the environment variable value associated with the provided name.

getFileInfo

Returns metadata information of the file specified in file path.

getUserHome

Returns the current user's home directory path.

getUsername

Returns the current user's name.

readDir

Reads the directory and returns a list of files and directories # inside the specified directory

remove

Removes the specified file or directory. If recursive flag is true, Removes the path and any children # it contains.

rename

Renames(Moves) old path to new path. If new path already exists and it is not a directory, this replaces the file.

tempDir

Returns the default directory to use for temporary files.

uuid

Returns a random UUID string.

copy

(string sourcePath, string destinationPath, boolean replaceExisting)

returns error?

Copy file/directory in old path to new path. If new path already exists, this replaces the file.

Parameters

  • sourcePath string
  • String value of old file path.

  • destinationPath string
  • String value of new file path.

  • replaceExisting boolean - false
  • Flag to allow replace if file already exists in destination path.

  • Return Type

    (error?)
  • Returns an error if failed to rename.

createDir

(string dir, boolean parentDirs)

returns string | error

Creates a new directory with the specified file name. If parentDirs flag is true, Creates a directory in specified path with any necessary parents.

Parameters

  • parentDirs boolean - false
  • Indicates whether the createDir should create non-existing parent directories.

  • Return Type

    (string | error)
  • Returns absolute path value of the created directory or an error if failed

createFile

(string path)

returns string | error

Creates a file in specified file path. Truncates if file already exists in the given path.

Parameters

  • path string
  • String value of file path.

  • Return Type

    (string | error)
  • Returns absolute path value of the created file or an error if failed

exists

(string path)

returns boolean

Reports whether file or directory exists for the given the path.

Parameters

  • path string
  • String value of file path.

  • Return Type

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

getCurrentDirectory

()

returns string

Returns the current working directory.

  • Return Type

    (string)
  • Current working directory or an empty string if the current working directory cannot be determined

getEnv

(string name)

returns string

Returns the environment variable value associated with the provided name.

Parameters

  • name string
  • Name of the environment variable

  • Return Type

    (string)
  • Environment variable value if it exists, otherwise an empty string

getFileInfo

(string path)

returns FileInfo | error

Returns metadata information of the file specified in file path.

Parameters

  • path string
  • String value of the file path.

  • Return Type

    (FileInfo | error)
  • Returns FileInfo instance with file metadata or an # error

getUserHome

()

returns string

Returns the current user's home directory path.

  • Return Type

    (string)
  • Current user's home directory if it can be determined, an empty string otherwise

getUsername

()

returns string

Returns the current user's name.

  • Return Type

    (string)
  • Current user's name if it can be determined, an empty string otherwise

readDir

(string path)

returns FileInfo[] | error

Reads the directory and returns a list of files and directories # inside the specified directory

Parameters

  • path string
  • String value of directory path.

  • Return Type

    (FileInfo[] | error)
  • Returns FileInfo array or an error if there is an error while # changing the mode.

remove

(string path, boolean recursive)

returns error?

Removes the specified file or directory. If recursive flag is true, Removes the path and any children # it contains.

Parameters

  • path string
  • String value of file/directory path.

  • recursive boolean - false
  • Indicates whether the remove should recursively remove all the file inside the given directory.

  • Return Type

    (error?)
  • Returns an error if failed to remove.

rename

(string oldPath, string newPath)

returns error?

Renames(Moves) old path to new path. If new path already exists and it is not a directory, this replaces the file.

Parameters

  • oldPath string
  • String value of old file path.

  • newPath string
  • String value of new file path.

  • Return Type

    (error?)
  • Returns an error if failed to rename.

tempDir

()

returns string

Returns the default directory to use for temporary files.

  • Return Type

    (string)
  • Temporary directory location.

uuid

()

returns string

Returns a random UUID string.

  • Return Type

    (string)
  • The random string