public interface FileSystem
Truffle files.| Modifier and Type | Method and Description |
|---|---|
void |
checkAccess(Path path,
Set<? extends AccessMode> modes,
LinkOption... linkOptions)
Checks existence and accessibility of a file.
|
default void |
copy(Path source,
Path target,
CopyOption... options)
Copies source file to target file.
|
void |
createDirectory(Path dir,
FileAttribute<?>... attrs)
Creates a directory.
|
default void |
createLink(Path link,
Path existing)
Creates a new link for an existing file.
|
default void |
createSymbolicLink(Path link,
Path target,
FileAttribute<?>... attrs)
Creates a new symbolic link.
|
void |
delete(Path path)
Deletes a file.
|
default String |
getSeparator()
Returns the name separator used to separate names in a path string.
|
default void |
move(Path source,
Path target,
CopyOption... options)
Moves (renames) source file to target file.
|
SeekableByteChannel |
newByteChannel(Path path,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
Opens or creates a file returning a
SeekableByteChannel to access the file content. |
DirectoryStream<Path> |
newDirectoryStream(Path dir,
DirectoryStream.Filter<? super Path> filter)
Returns directory entries.
|
Path |
parsePath(String path)
Parses a path from a
String. |
Path |
parsePath(URI uri)
Parses a path from an
URI. |
Map<String,Object> |
readAttributes(Path path,
String attributes,
LinkOption... options)
Reads a file's attributes as a bulk operation.
|
default Path |
readSymbolicLink(Path link)
Reads the target of the symbolic link.
|
default void |
setAttribute(Path path,
String attribute,
Object value,
LinkOption... options)
Sets a file's attribute.
|
default void |
setCurrentWorkingDirectory(Path currentWorkingDirectory)
Sets the current working directory.
|
Path |
toAbsolutePath(Path path)
Resolves given path to an absolute path.
|
Path |
toRealPath(Path path,
LinkOption... linkOptions)
Returns the real (canonical) path of an existing file.
|
Path parsePath(String path)
path - the string path to be converted to PathPathUnsupportedOperationException - when the FileSystem supports only URIvoid checkAccess(Path path, Set<? extends AccessMode> modes, LinkOption... linkOptions) throws IOException
path - the path to the file to checkmodes - the access modes to check, possibly empty to check existence only.linkOptions - options determining how the symbolic links should be handledNoSuchFileException - if the file denoted by the path does not existIOException - in case of IO errorSecurityException - if this FileSystem denied the operationvoid createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException
dir - the directory to createattrs - the optional attributes to set atomically when creating the directoryFileAlreadyExistsException - if a file on given path already existsIOException - in case of IO errorUnsupportedOperationException - if the attributes contain an attribute which cannot be
set atomicallySecurityException - if this FileSystem denied the operationvoid delete(Path path) throws IOException
path - the path to the file to deleteNoSuchFileException - if a file on given path does not existDirectoryNotEmptyException - if the path denotes a non empty directoryIOException - in case of IO errorSecurityException - if this FileSystem denied the operationSeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
SeekableByteChannel to access the file content.path - the path to the file to openoptions - the options specifying how the file should be openedattrs - the optional attributes to set atomically when creating the new fileSeekableByteChannelFileAlreadyExistsException - if StandardOpenOption.CREATE_NEW option is set and
a file already exists on given pathIOException - in case of IO errorUnsupportedOperationException - if the attributes contain an attribute which cannot be
set atomicallyIllegalArgumentException - in case of invalid options combinationSecurityException - if this FileSystem denied the operationDirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException
dir - the path to the directory to iterate entries forfilter - the filterDirectoryStreamNotDirectoryException - when given path does not denote a directoryIOException - in case of IO errorSecurityException - if this FileSystem denied the operationPath toAbsolutePath(Path path)
path - the path to resolve, may be a non normalized pathPathSecurityException - if this FileSystem denied the operationPath toRealPath(Path path, LinkOption... linkOptions) throws IOException
path - the path to resolve, may be a non normalized pathlinkOptions - options determining how the symbolic links should be handledIOException - in case of IO errorSecurityException - if this FileSystem denied the operationMap<String,Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException
path - the path to file to read attributes forattributes - the attributes to read. The attributes parameter has the form:
[view-name:]attribute-list. The optional view-name corresponds to
AttributeView.name() and determines the set of attributes, the default
value is "basic". The attribute-list is a comma separated list of
attributes. If the attribute-list contains '*' then all the
attributes from given view are read.options - the options determining how the symbolic links should be handledMap containing the file attributes. The map's keys are attribute names,
map's values are the attribute valuesUnsupportedOperationException - if the attribute view is not supported. At least the
"basic" attribute view has to be supported by the file system.IllegalArgumentException - is the attribute-list is empty or contains an
unknown attributeIOException - in case of IO errorSecurityException - if this FileSystem denied the operationdefault void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException
path - the path to file to set an attribute toattribute - the attribute to set. The attribute parameter has the form:
[view-name:]attribute-name. The optional view-name corresponds to
AttributeView.name() and determines the set of attributes, the default
value is "basic". The attribute-name is a name of an attribute.value - the attribute valueoptions - the options determining how the symbolic links should be handledClassCastException - if value is not of the expected type or value is a
Collection containing element of a non expected typeUnsupportedOperationException - if the attribute view is not supported.IllegalArgumentException - is the attribute-name is an unknown attribute or
value has an inappropriate valueIOException - in case of IO errorSecurityException - if this FileSystem denied the operationdefault void copy(Path source, Path target, CopyOption... options) throws IOException
source - the path to file to copytarget - the path to the target fileoptions - the options specifying how the copy should be performed, see
StandardCopyOptionUnsupportedOperationException - if options contains unsupported optionFileAlreadyExistsException - if the target path already exists and the options
don't contain StandardCopyOption.REPLACE_EXISTING optionDirectoryNotEmptyException - if the options contain
StandardCopyOption.REPLACE_EXISTING but the target is a non empty
directoryIOException - in case of IO errorSecurityException - if this FileSystem denied the operationdefault void move(Path source, Path target, CopyOption... options) throws IOException
source - the path to file to movetarget - the path to the target fileoptions - the options specifying how the move should be performed, see
StandardCopyOptionUnsupportedOperationException - if options contains unsupported optionFileAlreadyExistsException - if the target path already exists and the options
don't contain StandardCopyOption.REPLACE_EXISTING optionDirectoryNotEmptyException - if the options contain
StandardCopyOption.REPLACE_EXISTING but the target is a non empty
directoryAtomicMoveNotSupportedException - if the options contain
StandardCopyOption.ATOMIC_MOVE but file cannot be moved atomicallyIOException - in case of IO errorSecurityException - if this FileSystem denied the operationdefault void createLink(Path link, Path existing) throws IOException
link - the path to link to createexisting - the path to existing fileUnsupportedOperationException - if links are not supported by file systemFileAlreadyExistsException - if a file on given link path already existsIOException - in case of IO errorSecurityException - if this FileSystem denied the operationdefault void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException
link - the path to symbolic link to createtarget - the target path of the symbolic linkattrs - the optional attributes to set atomically when creating the new symbolic linkUnsupportedOperationException - if symbolic links are not supported by file systemFileAlreadyExistsException - if a file on given link path already existsIOException - in case of IO errorSecurityException - if this FileSystem denied the operationdefault Path readSymbolicLink(Path link) throws IOException
link - the path to symbolic link to readPath representing the symbolic link targetUnsupportedOperationException - if symbolic links are not supported by file systemNotLinkException - if the link does not denote a symbolic linkIOException - in case of IO errorSecurityException - if this FileSystem denied the operationdefault void setCurrentWorkingDirectory(Path currentWorkingDirectory)
FileSystem operations.currentWorkingDirectory - the new current working directoryUnsupportedOperationException - if setting of the current working directory is not
supportedIllegalArgumentException - if the currentWorkingDirectory is not a valid
current working directorySecurityException - if currentWorkingDirectory is not readabledefault String getSeparator()
toString() method.