Directory

public interface Directory implements Child<Directory>, Entity, FeatureProvider

This interface represents a directory in a file system. A directory may contain other directories or files. If the directory is the root of the filesystem it won't have a parent otherwise the parent mustn't be null

Functions

Link copied to clipboard
public Unit addDirectoryListener(IOAction action, Function1<DirectoryEvent, Unit> listener)

Adds a new DirectoryEventListener to this directory using the given listener lambda

Link copied to clipboard
public Unit addFileListener(IOAction action, Function1<FileEvent, Unit> listener)

Adds a new FileEventListener to this directory using the given listener lambda

Link copied to clipboard
public Unit addListener(IOAction action, DirectoryEventListener listener)
public Unit addListener(IOAction action, FileEventListener listener)

Adds the listener to this directory to listen for events with the given action

Link copied to clipboard
public abstract Boolean available(Feature feature)

Checks if the given feature is available in this class or not.

Link copied to clipboard
public abstract Unit create()

Creates this entity. The meaning of creation depends on the filesystem implementation. Regardless of the implementation, after using create the result of exists must be true

Link copied to clipboard
public abstract Unit delete()

Deletes this entity. The meaning of deletion depends on the filesystem implementation. Regardless of the implementation, after using delete the result of exists must be false

Link copied to clipboard
public abstract Boolean exists()

Returns if this entity exists or not.

Link copied to clipboard
public abstract List<Directory> getDirectories()

Returns a list of all directories contained within this directory. The list has no particular order

Link copied to clipboard
public abstract Directory getDirectory(String path)

Returns the directory with the given path resolved from this directory. The path may be a single element which is the files name or a path separated by /.

Link copied to clipboard
public abstract File getFile(String path)

Returns the file with the given path resolved from this directory. The path may be a single element which is the files name or a path separated by /.

Link copied to clipboard
public abstract List<File> getFiles()

Returns a list of all files contained within this directory. The list has no particular order

Link copied to clipboard
public abstract String getName()

Returns the name of this entity.

Link copied to clipboard
public abstract Directory getParent()

The parent of this child if there is one. If parent is null that means this object is the root object of the parent-child chain

Link copied to clipboard
public String getPath(Character separator)

Returns the path representation of this entity. Each entity in the path is separated with the separator. The path returned by this method without changing the separator can be used with Directory.getDirectory or Directory.getFile on the root directory of the filesystem to get this entity again.

Link copied to clipboard
public Boolean isRoot()

Returns if this directory is the root of its FileSystem.

Link copied to clipboard
public Long size()

Returns the size of this directory. The size of the directory will be the sum of all files and directories. This means the size will be calculated recursively. If the directory does not exist the size will be -1

Inheritors

Link copied to clipboard
Link copied to clipboard