saker.build Documentation TaskDoc JavaDoc Packages
public abstract class LocalFileProvider implements SakerFileProvider
Root file provider backed by the local file system.

The local file provider operates on Paths and uses the local FileSystem instance for modifying the files. The instance is retrieved using FileSystems.getDefault().

Some methods in this class can accept Path instead of SakerPath. The passed paths should all be bound to the default filesystem, if they're not, an InvalidPathFormatException is thrown.

Singleton, use getInstance() to retrieve an instance.

Methods
public ListenerToken
Adds a file event listener for the specified directory.
public ListenerToken
Adds a file event listener for the specified directory.
public void
Clears the directory and all subdirectories at the specified path.
public void
Clears the directory and all subdirectories at the specified path.
public void
Creates the directory and necessary parent directors at the given path.
public void
Creates the directory and necessary parent directors at the given path.
public void
delete(Path path)
Deletes a file or directory at the given path.
public void
Deletes a file or directory at the given path.
public NavigableSet<String>
Deletes the children of a directory recursively, if the name of a given child is not in the specified set.
public NavigableSet<String>
Deletes the children of a directory recursively, if the name of a given child is not in the specified set.
public void
Deletes a file or directory at the given path, recursively if it is a directory.
public void
Deletes a file or directory at the given path, recursively if it is a directory.
public int
Deletes the file at the given path if the type of it is not the specified one.
public int
Deletes the file at the given path if the type of it is not the specified one.
public ByteSink
ensureWriteOpenOutput(Path path, int operationflag, OpenOption... openoptions)
Ensures a write request for the given path and opens an output stream to it.
public ByteSink
ensureWriteOpenOutput(SakerPath path, int operationflag, OpenOption... openoptions)
Ensures a write request for the given path and opens an output stream to it.
public int
ensureWriteRequest(Path path, int filetype, int opflag)
Ensures that a write request to the given path can be initiated with the given type.
public int
ensureWriteRequest(SakerPath path, int filetype, int opflag)
Ensures that a write request to the given path can be initiated with the given type.
public ByteArrayRegion
getAllBytes(Path path, OpenOption... openoptions)
Gets all of the byte contents of the file at the specified path.
public ByteArrayRegion
getAllBytes(SakerPath path, OpenOption... openoptions)
Gets all of the byte contents of the file at the specified path.
public NavigableMap<String, ? extends FileEntry>
Gets the entries in the directory denoted by the argument path.
public NavigableMap<String, ? extends FileEntry>
Gets the entries in the directory denoted by the argument path.
public NavigableMap<SakerPath, ? extends FileEntry>
Collects the entries in the specified directory, recursively.
public NavigableMap<SakerPath, ? extends FileEntry>
Collects the entries in the specified directory, recursively.
public Entry<String, ? extends FileEntry>
Gets the attributes of a file in the directory specified by the argument path.
public Entry<String, ? extends FileEntry>
Gets the attributes of a file in the directory specified by the argument path.
public NavigableSet<String>
Gets the names of the files present in the directory denoted by the specified path.
public NavigableSet<String>
Gets the names of the files present in the directory denoted by the specified path.
public FileEntry
getFileAttributes(Path file, LinkOption... linkoptions)
Gets the attributes of the file at the specified path.
public FileEntry
getFileAttributes(SakerPath path, LinkOption... linkoptions)
Gets the attributes of the file at the specified path.
public static LocalFileProvider
Gets the singleton instance for the local file system.
public ProviderHolderPathKey
Creates a path key for the given path and this file provider.
public ProviderHolderPathKey
Creates a path key for the given path and this file provider.
public static PathKey
Creates a path key for the given path and the local file provider key.
public static PathKey
Creates a path key for the given path and the local file provider key.
public Set<PosixFilePermission>
Gets the posix file permissions of the file at the given path.
public Set<PosixFilePermission>
Gets the posix file permissions of the file at the given path.
public RootFileProviderKey
Gets the file provider key for this file provider.
public static RootFileProviderKey
Same as getProviderKey(), but can be called statically.
public NavigableSet<String>
Gets the file system roots of this file provider.
public NavigableSet<String>
Gets the names of subdirectories in the directory denoted by the specified path.
public NavigableSet<String>
Gets the names of subdirectories in the directory denoted by the specified path.
public FileHashResult
hash(Path path, String algorithm, OpenOption... openoptions)
Creates a hash using the specified algorithm based on the contents of the file at the specified path.
public FileHashResult
hash(SakerPath path, String algorithm, OpenOption... openoptions)
Creates a hash using the specified algorithm based on the contents of the file at the specified path.
public boolean
isChanged(Path path, long size, long modificationmillis, LinkOption... linkoptions)
Checks if the given attributes of a file at the specified path are the same or not.
public boolean
isChanged(SakerPath path, long size, long modificationmillis, LinkOption... linkoptions)
Checks if the given attributes of a file at the specified path are the same or not.
public boolean
Modifies the posix file permissions for the file at the given path.
public boolean
Modifies the posix file permissions for the file at the given path.
public void
moveFile(Path source, Path target, CopyOption... copyoptions)
Moves a file from on location to another.
public void
moveFile(SakerPath source, SakerPath target, CopyOption... copyoptions)
Moves a file from on location to another.
public ByteSource
openInput(Path path, OpenOption... openoptions)
Opens an input stream to the file at the specified path.
public ByteSource
openInput(SakerPath path, OpenOption... openoptions)
Opens an input stream to the file at the specified path.
public InputStream
openInputStream(Path path, OpenOption... openoptions)
Opens an input stream to the file at the specified path.
public InputStream
openInputStream(SakerPath path, OpenOption... openoptions)
public ByteSink
openOutput(Path path, OpenOption... openoptions)
Opens an output stream to the file at the specified path.
public ByteSink
openOutput(SakerPath path, OpenOption... openoptions)
Opens an output stream to the file at the specified path.
public OutputStream
openOutputStream(Path path, OpenOption... openoptions)
Opens an output stream to the file at the specified path.
public OutputStream
openOutputStream(SakerPath path, OpenOption... openoptions)
Opens an output stream to the file at the specified path.
public void
Removes the file listeners in a bulk operation.
public static Path
Validation method for ensuring that the argument path is absolute and associated with the local file system.
public void
setLastModifiedMillis(Path path, long millis)
Sets the last modified time of the file at the given path.
public void
setLastModifiedMillis(SakerPath path, long millis)
Sets the last modified time of the file at the given path.
public void
Sets the last modified time of the file at the given path.
public boolean
Sets the posix file permissions for the file at the given path.
public boolean
Sets the posix file permissions for the file at the given path.
public static Path
Converts the argument absolute path to a local Path for the local file system.
public String
Returns a string representation of the object.
public long
writeTo(Path path, ByteSink out, OpenOption... openoptions)
Writes the contents of the file at the given path to the specified output stream.
public long
writeTo(SakerPath path, ByteSink out, OpenOption... openoptions)
Writes the contents of the file at the given path to the specified output stream.
public long
writeToFile(InputStream is, Path path, OpenOption... openoptions)
Writes the contents from the given input stream to the specified output file path.
public long
writeToStream(Path path, OutputStream os, OpenOption... openoptions)
Writes the contents of the file at the given path to the specified output stream.
public long
Writes the contents of the file at the given path to the specified output stream.
Documentation included from: SakerFileProvider
Adds a file event listener for the specified directory.

If the specified directory doesn't exist, the provider can either fail or succeed for installing the listener.

Callers should keep a strong reference to the returned token, and call FileEventListener.ListenerToken.removeListener() when the listener is no longer needed. Removing all references to the returned token is not sufficient for removing the listener from the provider.

Listeners might receive events before this method finishes.

The listener will receive file event changes with file names which are a children of the specified directory.

directoryThe directory to install the listener to.
listenerThe listener to install.
The token for the installed listener.
IOExceptionIf the provider failed to install the listener.
Overridden from: SakerFileProvider
Adds a file event listener for the specified directory.

If the specified directory doesn't exist, the provider can either fail or succeed for installing the listener.

Callers should keep a strong reference to the returned token, and call FileEventListener.ListenerToken.removeListener() when the listener is no longer needed. Removing all references to the returned token is not sufficient for removing the listener from the provider.

Listeners might receive events before this method finishes.

The listener will receive file event changes with file names which are a children of the specified directory.

directoryThe directory to install the listener to.
listenerThe listener to install.
The token for the installed listener.
IOExceptionIf the provider failed to install the listener.
public void clearDirectoryRecursively(Path directory) throws IOException
Documentation included from: SakerFileProvider
Clears the directory and all subdirectories at the specified path.

This method follows symbolic links for retrieving the children, but doesn't when deleting the entries. Meaning, if a directory contains a link, the link will be deleted and the directory at the end of the link will not be cleared.

directoryThe path to the directory to clear.
IOExceptionIn case of I/O error.
Overridden from: SakerFileProvider
Clears the directory and all subdirectories at the specified path.

This method follows symbolic links for retrieving the children, but doesn't when deleting the entries. Meaning, if a directory contains a link, the link will be deleted and the directory at the end of the link will not be cleared.

pathThe path to the directory to clear.
IOExceptionIn case of I/O error.
Documentation included from: SakerFileProvider
Creates the directory and necessary parent directors at the given path.

If the directories cannot be created due to a non-directory file is already present at the path or at one of its parent paths, the method will fail.

pathThe path to create the directory at.
FileAlreadyExistsExceptionIf there is already a non-directory file at the path (or any parent paths).
IOExceptionIn case of I/O error.
public void createDirectories(SakerPath path) throws IOException
Overridden from: SakerFileProvider
Creates the directory and necessary parent directors at the given path.

If the directories cannot be created due to a non-directory file is already present at the path or at one of its parent paths, the method will fail.

pathThe path to create the directory at.
IOExceptionIn case of I/O error.
Documentation included from: SakerFileProvider
Deletes a file or directory at the given path.

The method will fail if the path denotes a directory and it is not empty.

If the path denotes a symbolic link, only the link will be deleted.

If there is no file at the given path, the method will succeed, and won't throw an exception. Therefore this methods works in the manner of "delete if exists".

pathThe path to delete.
IOExceptionIn case of I/O error.
DirectoryNotEmptyExceptionIf the path denotes a file and it's not empty.
Overridden from: SakerFileProvider
Deletes a file or directory at the given path.

The method will fail if the path denotes a directory and it is not empty.

If the path denotes a symbolic link, only the link will be deleted.

If there is no file at the given path, the method will succeed, and won't throw an exception. Therefore this methods works in the manner of "delete if exists".

pathThe path to delete.
IOExceptionIn case of I/O error.
DirectoryNotEmptyExceptionIf the path denotes a file and it's not empty.
Documentation included from: SakerFileProvider
Deletes the children of a directory recursively, if the name of a given child is not in the specified set.

If a directory child is a directory, it will be recursively deleted, meaning any of its subdirectories will be deleted too.

This method doesn't follow symbolic links. Meaning, if a directory contains a link, the link will be deleted and the directory at the end of the link will not be cleared.

pathThe path to the directory.
childfilenamesA set of names in the specified directory to not delete.
The names of the actually deleted files. The returned set is ordered by natural order.
IOExceptionIn case of I/O error.
Overridden from: SakerFileProvider
Deletes the children of a directory recursively, if the name of a given child is not in the specified set.

If a directory child is a directory, it will be recursively deleted, meaning any of its subdirectories will be deleted too.

This method doesn't follow symbolic links. Meaning, if a directory contains a link, the link will be deleted and the directory at the end of the link will not be cleared.

pathThe path to the directory.
childfilenamesA set of names in the specified directory to not delete.
The names of the actually deleted files. The returned set is ordered by natural order.
IOExceptionIn case of I/O error.
public void deleteRecursively(Path path) throws IOException
Documentation included from: SakerFileProvider
Deletes a file or directory at the given path, recursively if it is a directory.

This method will delete all files at the given path, clearing the directory beforehand if necessary.

This method doesn't follow symbolic links. Links to directories will be deleted, the directories won't be cleared if they are not under the specified path.

pathThe path to delete.
IOExceptionIn case of I/O error.
public void deleteRecursively(SakerPath path) throws IOException
Overridden from: SakerFileProvider
Deletes a file or directory at the given path, recursively if it is a directory.

This method will delete all files at the given path, clearing the directory beforehand if necessary.

This method doesn't follow symbolic links. Links to directories will be deleted, the directories won't be cleared if they are not under the specified path.

pathThe path to delete.
IOExceptionIn case of I/O error.
public int deleteRecursivelyIfNotFileType(Path path, int filetype) throws IOException
Documentation included from: SakerFileProvider
Deletes the file at the given path if the type of it is not the specified one.

This method reads the attributes at the given path, and deletes the file recursively if it doesn't match the expected.

The attribute reading follows symbolic links, the deletion doesn't.

The file type argument should be one of the file type constants in FileEntry.

pathThe path to the file.
filetypeThe expected file type.
The current file type at the path. Either same as the argument, or FileEntry.TYPE_NULL to signal that it was deleted.
IOExceptionIn case of I/O error.
public int deleteRecursivelyIfNotFileType(SakerPath path, int filetype) throws IOException
Overridden from: SakerFileProvider
Deletes the file at the given path if the type of it is not the specified one.

This method reads the attributes at the given path, and deletes the file recursively if it doesn't match the expected.

The attribute reading follows symbolic links, the deletion doesn't.

The file type argument should be one of the file type constants in FileEntry.

pathThe path to the file.
filetypeThe expected file type.
The current file type at the path. Either same as the argument, or FileEntry.TYPE_NULL to signal that it was deleted.
IOExceptionIn case of I/O error.
public ByteSink ensureWriteOpenOutput(Path path, int operationflag, OpenOption... openoptions) throws IOException, NullPointerException
Documentation included from: SakerFileProvider
Ensures a write request for the given path and opens an output stream to it.

The method works the same way as if SakerFileProvider.ensureWriteRequest(SakerPath, int, int) and SakerFileProvider.openOutput(SakerPath, OpenOption...) are called subsequently. This corresponds to the default implementation of:

 ensureWriteRequest(path, FileEntry.TYPE_FILE, operationflag);
 return openOutput(path, openoptions);
 
pathThe output file path.
operationflagThe operation flag to take into account. Acceptable flags: OPERATION_FLAG_NO_RECURSIVE_DIRECTORY_DELETE, OPERATION_FLAG_DELETE_INTERMEDIATE_FILES.
openoptionsThe opening options for the output.
An opened output stream.
IOExceptionIn case of I/O error.
NullPointerExceptionIf any of the arguments are null.
saker.build 0.8.15
public ByteSink ensureWriteOpenOutput(SakerPath path, int operationflag, OpenOption... openoptions) throws IOException, NullPointerException
Overridden from: SakerFileProvider
Ensures a write request for the given path and opens an output stream to it.

The method works the same way as if SakerFileProvider.ensureWriteRequest(SakerPath, int, int) and SakerFileProvider.openOutput(SakerPath, OpenOption...) are called subsequently. This corresponds to the default implementation of:

 ensureWriteRequest(path, FileEntry.TYPE_FILE, operationflag);
 return openOutput(path, openoptions);
 
pathThe output file path.
operationflagThe operation flag to take into account. Acceptable flags: OPERATION_FLAG_NO_RECURSIVE_DIRECTORY_DELETE, OPERATION_FLAG_DELETE_INTERMEDIATE_FILES.
openoptionsThe opening options for the output.
An opened output stream.
IOExceptionIn case of I/O error.
NullPointerExceptionIf any of the arguments are null.
saker.build 0.8.15
public int ensureWriteRequest(Path path, int filetype, int opflag) throws IOException
Documentation included from: SakerFileProvider
Ensures that a write request to the given path can be initiated with the given type.

This method examines the current file at the given path, and ensures that the file is either has the same type, or a write request can be initiated to it.

The argument file type and behaviour based on it is the following:

  • FileEntry.TYPE_FILE: If there is a directory at the path, it will be deleted recursively*. If there is a file at the path, no operation will be done as it can be overwritten. If not all parent directories exist at the path, the parent directories will be created recursively. This ensures that a following SakerFileProvider.openOutput(SakerPath, OpenOption...) can succeed.
    * If the SakerFileProvider.OPERATION_FLAG_NO_RECURSIVE_DIRECTORY_DELETE is specified, the encountered directory will only be deleted if it is empty. An exception is thrown instead if it is not empty.
  • FileEntry.TYPE_DIRECTORY: If there is a non-directory file at the path, it will be deleted. If there is a directory at the path, no operation will be done. If there is no file at the path, all directories will be created, including the one at the path as well.
The directory creation for parent paths in the above behaviours works the same way as SakerFileProvider.createDirectories(SakerPath).

This method is mainly useful to batch the attribute reading-deletion-file creation operations into one call, therefore ensuring that a given path is writeable for the given file type.

Note that this function is not atomic. The checking of the currently present file, deletions, and creation are not done atomically, therefore this method may fail if concurrent modifications distrupt it. It is recommended for callers to ensure private and synchronized access to the given path.

pathThe path.
filetypeThe file type to ensure the write request for.
opflagThe operation flag to take into account. Acceptable flags: OPERATION_FLAG_NO_RECURSIVE_DIRECTORY_DELETE, OPERATION_FLAG_DELETE_INTERMEDIATE_FILES.
The result flags describing the changes made by this method. See RESULT_NO_CHANGES, RESULT_FLAG_FILES_DELETED, RESULT_FLAG_DIRECTORY_CREATED.
IOExceptionIn case of I/O error.
public int ensureWriteRequest(SakerPath path, int filetype, int opflag) throws IOException
Overridden from: SakerFileProvider
Ensures that a write request to the given path can be initiated with the given type.

This method examines the current file at the given path, and ensures that the file is either has the same type, or a write request can be initiated to it.

The argument file type and behaviour based on it is the following:

  • FileEntry.TYPE_FILE: If there is a directory at the path, it will be deleted recursively*. If there is a file at the path, no operation will be done as it can be overwritten. If not all parent directories exist at the path, the parent directories will be created recursively. This ensures that a following SakerFileProvider.openOutput(SakerPath, OpenOption...) can succeed.
    * If the SakerFileProvider.OPERATION_FLAG_NO_RECURSIVE_DIRECTORY_DELETE is specified, the encountered directory will only be deleted if it is empty. An exception is thrown instead if it is not empty.
  • FileEntry.TYPE_DIRECTORY: If there is a non-directory file at the path, it will be deleted. If there is a directory at the path, no operation will be done. If there is no file at the path, all directories will be created, including the one at the path as well.
The directory creation for parent paths in the above behaviours works the same way as SakerFileProvider.createDirectories(SakerPath).

This method is mainly useful to batch the attribute reading-deletion-file creation operations into one call, therefore ensuring that a given path is writeable for the given file type.

Note that this function is not atomic. The checking of the currently present file, deletions, and creation are not done atomically, therefore this method may fail if concurrent modifications distrupt it. It is recommended for callers to ensure private and synchronized access to the given path.

pathThe path.
filetypeThe file type to ensure the write request for.
opflagThe operation flag to take into account. Acceptable flags: OPERATION_FLAG_NO_RECURSIVE_DIRECTORY_DELETE, OPERATION_FLAG_DELETE_INTERMEDIATE_FILES.
The result flags describing the changes made by this method. See RESULT_NO_CHANGES, RESULT_FLAG_FILES_DELETED, RESULT_FLAG_DIRECTORY_CREATED.
IOExceptionIn case of I/O error.
public ByteArrayRegion getAllBytes(Path path, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Gets all of the byte contents of the file at the specified path.
pathThe path to the file.
openoptionsThe opening options for the input.
The byte contents of the file.
IOExceptionIn case of I/O error.
public ByteArrayRegion getAllBytes(SakerPath path, OpenOption... openoptions) throws IOException
Overridden from: SakerFileProvider
Gets all of the byte contents of the file at the specified path.
pathThe path to the file.
openoptionsThe opening options for the input.
The byte contents of the file.
IOExceptionIn case of I/O error.
Documentation included from: SakerFileProvider
Gets the entries in the directory denoted by the argument path.

The result contains the file names mapped to their attributes.

This method follows symbolic links when determining the attributes.

pathThe path to the directory.
The directory entries. The returned map is ordered by natural order.
IOExceptionIn case of I/O error.
Overridden from: SakerFileProvider
Gets the entries in the directory denoted by the argument path.

The result contains the file names mapped to their attributes.

This method follows symbolic links when determining the attributes.

pathThe path to the directory.
The directory entries. The returned map is ordered by natural order.
IOExceptionIn case of I/O error.
Documentation included from: SakerFileProvider
Collects the entries in the specified directory, recursively.

This method contains every file entry that is under the specified directory and its subdirectories.

Use this method judiciously as a large number of files might be queried.

The file attribute values in the result map are mapped to their relative path based on the argument path.

This method follows symbolic links for directories and when determining attributes.

pathThe path to the directory.
The recursively collected file entries mapped to their paths relative to the argument. The returned map is ordered by natural order.
IOExceptionIn case of I/O error.
Overridden from: SakerFileProvider
Collects the entries in the specified directory, recursively.

This method contains every file entry that is under the specified directory and its subdirectories.

Use this method judiciously as a large number of files might be queried.

The file attribute values in the result map are mapped to their relative path based on the argument path.

This method follows symbolic links for directories and when determining attributes.

pathThe path to the directory.
The recursively collected file entries mapped to their paths relative to the argument. The returned map is ordered by natural order.
IOExceptionIn case of I/O error.
Documentation included from: SakerFileProvider
Gets the attributes of a file in the directory specified by the argument path.

This method only returns non-null if there is a directory at the denoted path, and in that directory there is only one file. The attributes for the file is returned.

This method follows symbolic links when determining the attribute.

pathThe directory to get the entry for.
A map entry where the key is the name of the found file, the value is the attributes of the file. null if no file or more than one was found.
IOExceptionIn case of I/O error.
Overridden from: SakerFileProvider
Gets the attributes of a file in the directory specified by the argument path.

This method only returns non-null if there is a directory at the denoted path, and in that directory there is only one file. The attributes for the file is returned.

This method follows symbolic links when determining the attribute.

pathThe directory to get the entry for.
A map entry where the key is the name of the found file, the value is the attributes of the file. null if no file or more than one was found.
IOExceptionIn case of I/O error.
Documentation included from: SakerFileProvider
Gets the names of the files present in the directory denoted by the specified path.

This method doesn't follow symbolic links.

pathThe path to the directory.
A set of file names which are present in the given directory. The returned set is ordered by natural order.
IOExceptionIn case of I/O error.
Overridden from: SakerFileProvider
Gets the names of the files present in the directory denoted by the specified path.

This method doesn't follow symbolic links.

pathThe path to the directory.
A set of file names which are present in the given directory. The returned set is ordered by natural order.
IOExceptionIn case of I/O error.
public FileEntry getFileAttributes(Path file, LinkOption... linkoptions) throws IOException
Documentation included from: SakerFileProvider
Gets the attributes of the file at the specified path.
fileThe path to the file.
linkoptionsLink options to use when retrieving the attributes.
The attributes of the file.
IOExceptionIn case of I/O error.
public FileEntry getFileAttributes(SakerPath path, LinkOption... linkoptions) throws IOException
Overridden from: SakerFileProvider
Gets the attributes of the file at the specified path.
pathThe path to the file.
linkoptionsLink options to use when retrieving the attributes.
The attributes of the file.
IOExceptionIn case of I/O error.
Gets the singleton instance for the local file system.
The file provider instance.
Creates a path key for the given path and this file provider.
pathThe path.
The created path key.
Creates a path key for the given path and this file provider.
pathThe path.
The created path key.
public static PathKey getPathKeyStatic(Path path)
Creates a path key for the given path and the local file provider key.
pathThe path.
The created path key.
public static PathKey getPathKeyStatic(SakerPath path)
Creates a path key for the given path and the local file provider key.
pathThe path.
The created path key.
Documentation included from: SakerFileProvider
Gets the posix file permissions of the file at the given path.

The method will query the posix file permissions of the specified file if the underlying file system supports them.

The method does not throw an exception if the underlying filesystem doesn't support posix file permissions.

pathThe path of the file.
The posix file permissions of the file or null if the underlying filesystem doesn't support them.
NullPointerExceptionIf the path argument is null.
IOExceptionIn case of I/O error.
saker.build 0.8.13
Overridden from: SakerFileProvider
Gets the posix file permissions of the file at the given path.

The method will query the posix file permissions of the specified file if the underlying file system supports them.

The method does not throw an exception if the underlying filesystem doesn't support posix file permissions.

pathThe path of the file.
The posix file permissions of the file or null if the underlying filesystem doesn't support them.
NullPointerExceptionIf the path argument is null.
IOExceptionIn case of I/O error.
saker.build 0.8.13
Overridden from: SakerFileProvider
Gets the file provider key for this file provider.

If this file provider is a root provider, then the result will be an instance of RootFileProviderKey.

The file provider key.
Same as getProviderKey(), but can be called statically.
The file provider key.
Overridden from: SakerFileProvider
Gets the file system roots of this file provider.

File system roots do not change during the lifetime of a file provider. They are normalized according to the rules of SakerPath.normalizeRoot(String).

Note: It can happen that some file system drives are changed during the lifetime of a file provider. (E.g. USB drive inserted/removed, etc...) The file provider implementations are not required to recognize these changes, and restarting the build system process might be required to handle the file system changes.

An unmodifiable set of root names for this file provider. The returned set is ordered by natural order.
Documentation included from: SakerFileProvider
Gets the names of subdirectories in the directory denoted by the specified path.

This method follows symbolic links when determining if an entry is considered a directory.

pathThe path to the directory.
A set of directory names which are present in the given directory. The returned set is ordered by natural order.
IOExceptionIn case of I/O error.
Overridden from: SakerFileProvider
Gets the names of subdirectories in the directory denoted by the specified path.

This method follows symbolic links when determining if an entry is considered a directory.

pathThe path to the directory.
A set of directory names which are present in the given directory. The returned set is ordered by natural order.
IOExceptionIn case of I/O error.
public FileHashResult hash(Path path, String algorithm, OpenOption... openoptions) throws NoSuchAlgorithmException, IOException
Documentation included from: SakerFileProvider
Creates a hash using the specified algorithm based on the contents of the file at the specified path.

This method will read the contents of the file at the specified path and use the appropriate MessageDigest to create a hash of its contents.

When using RMI, it is preferable to call this method instead of opening the stream on client side and reading the contents, as it can avoid transferring the whole content of the file over the network.

pathThe path to the file.
algorithmThe algorithm to use for hashing.
openoptionsThe opening options to use when opening the file.
The computed hash.
NoSuchAlgorithmExceptionIf the hashing algorithm not found.
IOExceptionIn case of I/O error.
public FileHashResult hash(SakerPath path, String algorithm, OpenOption... openoptions) throws NoSuchAlgorithmException, IOException
Overridden from: SakerFileProvider
Creates a hash using the specified algorithm based on the contents of the file at the specified path.

This method will read the contents of the file at the specified path and use the appropriate MessageDigest to create a hash of its contents.

When using RMI, it is preferable to call this method instead of opening the stream on client side and reading the contents, as it can avoid transferring the whole content of the file over the network.

pathThe path to the file.
algorithmThe algorithm to use for hashing.
openoptionsThe opening options to use when opening the file.
The computed hash.
NoSuchAlgorithmExceptionIf the hashing algorithm not found.
IOExceptionIn case of I/O error.
public boolean isChanged(Path path, long size, long modificationmillis, LinkOption... linkoptions)
Documentation included from: SakerFileProvider
Checks if the given attributes of a file at the specified path are the same or not.

This method retrieves the attributes of the file at the path and compares the specified attributes.

pathThe path to the file.
sizeThe expected size of the file.
modificationmillisThe expected modification time of the file.
linkoptionsThe link options to use.
true if failed to retrieve the attributes, or the attributes changed.
public boolean isChanged(SakerPath path, long size, long modificationmillis, LinkOption... linkoptions)
Overridden from: SakerFileProvider
Checks if the given attributes of a file at the specified path are the same or not.

This method retrieves the attributes of the file at the path and compares the specified attributes.

pathThe path to the file.
sizeThe expected size of the file.
modificationmillisThe expected modification time of the file.
linkoptionsThe link options to use.
true if failed to retrieve the attributes, or the attributes changed.
public boolean modifyPosixFilePermissions(Path path, Set<PosixFilePermission> addpermissions, Set<PosixFilePermission> removepermissions) throws NullPointerException, IOException
Documentation included from: SakerFileProvider
Modifies the posix file permissions for the file at the given path.

The method takes two permission set arguments which control how the permissions should be modified. First all permissions in the add argument are added, then all permissions in the remove argument are removed.

The adding and removal are performed in a single filesystem operation.

If a permission is present in both add and remove permission sets, then it will be removed.

The method does not throw an exception if the underlying filesystem doesn't support posix file permissions.

pathThe path of the file.
addpermissionsThe permissons to add. May be null to not add anything.
removepermissionsThe permissions to remove. May be null to not remove anything.
true if the underlying filesystem supports posix file permissions. false otherwise.
NullPointerExceptionIf the path argument or any of the permission elements are null.
IOExceptionIn case of I/O error.
saker.build 0.8.13
public boolean modifyPosixFilePermissions(SakerPath path, Set<PosixFilePermission> addpermissions, Set<PosixFilePermission> removepermissions) throws NullPointerException, IOException
Overridden from: SakerFileProvider
Modifies the posix file permissions for the file at the given path.

The method takes two permission set arguments which control how the permissions should be modified. First all permissions in the add argument are added, then all permissions in the remove argument are removed.

The adding and removal are performed in a single filesystem operation.

If a permission is present in both add and remove permission sets, then it will be removed.

The method does not throw an exception if the underlying filesystem doesn't support posix file permissions.

pathThe path of the file.
addpermissionsThe permissons to add. May be null to not add anything.
removepermissionsThe permissions to remove. May be null to not remove anything.
true if the underlying filesystem supports posix file permissions. false otherwise.
NullPointerExceptionIf the path argument or any of the permission elements are null.
IOExceptionIn case of I/O error.
saker.build 0.8.13
public void moveFile(Path source, Path target, CopyOption... copyoptions) throws IOException
Documentation included from: SakerFileProvider
Moves a file from on location to another.
sourceThe file to move.
targetThe path to move the file to.
copyoptionsThe copy options to use.
IOExceptionIn case of I/O error.
public void moveFile(SakerPath source, SakerPath target, CopyOption... copyoptions) throws IOException
Overridden from: SakerFileProvider
Moves a file from on location to another.
sourceThe file to move.
targetThe path to move the file to.
copyoptionsThe copy options to use.
IOExceptionIn case of I/O error.
public ByteSource openInput(Path path, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Opens an input stream to the file at the specified path.

The OpenOption argument must contain elements which are enumerations.

The returned stream is not thread-safe.

pathThe path to the file.
openoptionsThe opening options for the input.
An opened stream.
IOExceptionIn case of I/O error.
public ByteSource openInput(SakerPath path, OpenOption... openoptions) throws IOException
Overridden from: SakerFileProvider
Opens an input stream to the file at the specified path.

The OpenOption argument must contain elements which are enumerations.

The returned stream is not thread-safe.

pathThe path to the file.
openoptionsThe opening options for the input.
An opened stream.
IOExceptionIn case of I/O error.
public InputStream openInputStream(Path path, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Opens an input stream to the file at the specified path.

The OpenOption argument must contain elements which are enumerations.

The returned stream is not thread-safe.

pathThe path to the file.
openoptionsThe opening options for the input.
An opened stream.
IOExceptionIn case of I/O error.
public ByteSink openOutput(Path path, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Opens an output stream to the file at the specified path.

The caller must close the returned stream to properly persist the written bytes to the stream. If the caller doesn't close the stream, data corruption might occur. If the stream is not closed, the data may not have been written to the disk. Implementations may cache the written bytes and flush them when close() is called.

If this method successfully returns, that doesn't necessarily mean that the file has been opened. Opening related exceptions may be thrown by the writing or closing methods of the returned stream.

The OpenOption argument must contain elements which are enumerations.

The returned stream is not thread-safe.

pathThe path to the file.
openoptionsThe opening options for the output.
An opened output stream.
IOExceptionIn case of I/O error.
public ByteSink openOutput(SakerPath path, OpenOption... openoptions) throws IOException
Overridden from: SakerFileProvider
Opens an output stream to the file at the specified path.

The caller must close the returned stream to properly persist the written bytes to the stream. If the caller doesn't close the stream, data corruption might occur. If the stream is not closed, the data may not have been written to the disk. Implementations may cache the written bytes and flush them when close() is called.

If this method successfully returns, that doesn't necessarily mean that the file has been opened. Opening related exceptions may be thrown by the writing or closing methods of the returned stream.

The OpenOption argument must contain elements which are enumerations.

The returned stream is not thread-safe.

pathThe path to the file.
openoptionsThe opening options for the output.
An opened output stream.
IOExceptionIn case of I/O error.
public OutputStream openOutputStream(Path path, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Opens an output stream to the file at the specified path.

The caller must close the returned stream to properly persist the written bytes to the stream. If the caller doesn't close the stream, data corruption might occur. If the stream is not closed, the data may not have been written to the disk. Implementations may cache the written bytes and flush them when close() is called.

If this method successfully returns, that doesn't necessarily mean that the file has been opened. Opening related exceptions may be thrown by the writing or closing methods of the returned stream.

The OpenOption argument must contain elements which are enumerations.

The returned stream is not thread-safe.

pathThe path to the file.
openoptionsThe opening options for the output.
An opened output stream.
IOExceptionIn case of I/O error.
public OutputStream openOutputStream(SakerPath path, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Opens an output stream to the file at the specified path.

The caller must close the returned stream to properly persist the written bytes to the stream. If the caller doesn't close the stream, data corruption might occur. If the stream is not closed, the data may not have been written to the disk. Implementations may cache the written bytes and flush them when close() is called.

If this method successfully returns, that doesn't necessarily mean that the file has been opened. Opening related exceptions may be thrown by the writing or closing methods of the returned stream.

The OpenOption argument must contain elements which are enumerations.

The returned stream is not thread-safe.

pathThe path to the file.
openoptionsThe opening options for the output.
An opened output stream.
IOExceptionIn case of I/O error.
public void removeFileEventListeners(Iterable<extends ListenerToken> listeners)
Overridden from: SakerFileProvider
Removes the file listeners in a bulk operation.

To remove a single file listener call FileEventListener.ListenerToken.removeListener().

The file listeners might still receive some events after this call, as the events can occur out of order. Listeners should handle that scenario gracefully.

The method will silently ignore any null elements in the argument.

listenersThe file listeners to remove.
Validation method for ensuring that the argument path is absolute and associated with the local file system.
pathThe path to validate-
The parameter path.
InvalidPathFormatExceptionIf the path is not absolute, or not associated with the default file system.
NullPointerExceptionIf the path is null.
public void setLastModifiedMillis(Path path, long millis) throws IOException
Documentation included from: SakerFileProvider
Sets the last modified time of the file at the given path.

The milliseconds are converted using FileTime.fromMillis(long).

pathThe file path.
millisThe modification time in milliseconds.
IOExceptionIn case of I/O error.
public void setLastModifiedMillis(SakerPath path, long millis) throws IOException
Overridden from: SakerFileProvider
Sets the last modified time of the file at the given path.

The milliseconds are converted using FileTime.fromMillis(long).

pathThe file path.
millisThe modification time in milliseconds.
IOExceptionIn case of I/O error.
public void setLastModifiedTime(Path path, FileTime time) throws IOException
Documentation included from: SakerFileProvider
Sets the last modified time of the file at the given path.

The milliseconds are converted using FileTime.fromMillis(long).

pathThe file path.
timeThe modification time in milliseconds.
IOExceptionIn case of I/O error.
Documentation included from: SakerFileProvider
Sets the posix file permissions for the file at the given path.

This method will only set the file permissions if the underlying filesystem supports it. In that case the method will return true. Otherwise false.

The method does not throw an exception if the underlying filesystem doesn't support posix file permissions.

pathThe path of the file.
permissionsThe permississions to set.
true if the underlying filesystem supports posix file permissions. false otherwise.
NullPointerExceptionIf any of the arguments are null.
IOExceptionIn case of I/O error.
saker.build 0.8.13
Overridden from: SakerFileProvider
Sets the posix file permissions for the file at the given path.

This method will only set the file permissions if the underlying filesystem supports it. In that case the method will return true. Otherwise false.

The method does not throw an exception if the underlying filesystem doesn't support posix file permissions.

pathThe path of the file.
permissionsThe permississions to set.
true if the underlying filesystem supports posix file permissions. false otherwise.
NullPointerExceptionIf any of the arguments are null.
IOExceptionIn case of I/O error.
saker.build 0.8.13
Converts the argument absolute path to a local Path for the local file system.
pathThe path to convert.
The localized path.
InvalidPathExceptionIf the path is not valid on the local filesystem.
InvalidPathFormatExceptionIf the argument is not an absolute path.
public String toString()
Overridden from: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
a string representation of the object.
public long writeTo(Path path, ByteSink out, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Writes the contents of the file at the given path to the specified output stream.
pathThe path to the file.
outThe output to write the file contents to.
openoptionsThe opening options for the input.
The amount of bytes written to the output stream.
IOExceptionIn case of I/O error.
public long writeTo(SakerPath path, ByteSink out, OpenOption... openoptions) throws IOException
Overridden from: SakerFileProvider
Writes the contents of the file at the given path to the specified output stream.
pathThe path to the file.
outThe output to write the file contents to.
openoptionsThe opening options for the input.
The amount of bytes written to the output stream.
IOExceptionIn case of I/O error.
public long writeToFile(InputStream is, Path path, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Writes the contents from the given input stream to the specified output file path.
isThe input to get the bytes from.
pathThe output file path.
openoptionsThe opening options for the output.
The amount of bytes written to the file.
IOExceptionIn case of I/O error.
public long writeToStream(Path path, OutputStream os, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Writes the contents of the file at the given path to the specified output stream.
pathThe path to the file.
osThe output to write the file contents to.
openoptionsThe opening options for the input.
The amount of bytes written to the output stream.
IOExceptionIn case of I/O error.
public long writeToStream(SakerPath path, OutputStream os, OpenOption... openoptions) throws IOException
Documentation included from: SakerFileProvider
Writes the contents of the file at the given path to the specified output stream.
pathThe path to the file.
osThe output to write the file contents to.
openoptionsThe opening options for the input.
The amount of bytes written to the output stream.
IOExceptionIn case of I/O error.