ballerina/file

Package Overview

This package contains functions to perform file system based operations such as create, delete, rename the file/directory, and retrieve metadata of the file.

For an example on the usage of the operations, see the File Example.

Directory Listener

The Directory Listener is used to listen to a directory in the local file system. It notifies when new files are created in the directory or when the existing files are deleted or modified.

For an example on the usage of the operations, see the Directory Listener Example.

Listeners

[1]

Listener

Represents the directory listener endpoint, which is used to listen to a directory in the local file system.

Functions

[19]

basename

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

copy

Copy the file/directory in the old path to the new path.

create

Creates a file in the specified file path.

createDir

Creates a new directory with the specified name.

createTemp

Creates a temporary file.

createTempDir

Creates a temporary directory.

getAbsolutePath

Retrieves the absolute path from the provided location.

getCurrentDir

Returns the current working directory.

getMetaData

Returns the metadata information of the file specified in the file path.

isAbsolutePath

Reports whether the path is absolute.

joinPath

Joins any number of path elements into a single path.

normalizePath

Normalizes a path value.

parentPath

Returns the enclosing parent directory.

readDir

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

relativePath

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

remove

Removes the specified file or directory.

rename

Renames(Moves) the old path with the new path.

splitPath

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

test

Tests a file path against a test condition .

Records

[3]

FileEvent

Represents an event which will trigger when there is a changes to listining direcotry.

ListenerConfig

Represents configurations that required for directory listener.

MetaData

Metadata record contains metadata information of a file.

Enums

[4]

CopyOption

Represents options that can be used when copying files/directories

DirOption

Represents options that can be used when creating or removing directories.

NormOption

Represents the options that can be passed to normalizePath function.

TestOption

Represents the options that can be passed to test function.

Errors

[1]

Error

Represents file system related errors.