-
- All Implemented Interfaces:
-
java.io.Serializable,java.lang.Comparable
public abstract class ExtendedFile extends File
File API with extended features.
The goal of this class is to extend missing features in the File API that are available in the NIO package but not possible to be re-implemented without low-level file system access. For instance, detecting file types other than regular files and directories, handling and creating hard links and symbolic links.
Another goal of this class is to provide a generalized API interface for custom file system backends. The library includes backends for accessing files locally, accessing files remotely via IPC, and accessing files through shell commands (by using
{@code SuFile}, included in the{@code io}module). The developer can get instances of this class with getFile.Implementations of this class is required to return the same type of ExtendedFile in all of its APIs returning Files. This means that, for example, if the developer is getting a list of files in a directory using a remote file system with listFiles, all files returned in the array will also be using the same remote file system backend.
-
-
Method Summary
Modifier and Type Method Description abstract booleanisBlock()abstract booleanisCharacter()abstract booleanisSymlink()abstract booleanisNamedPipe()abstract booleanisSocket()abstract booleancreateNewLink(String existing)Creates a new hard link named by this abstract pathname of an existing fileif and only if a file with this name does not yet exist. abstract booleancreateNewSymlink(String target)Creates a new symbolic link named by this abstract pathname to a target fileif and only if a file with this name does not yet exist. abstract InputStreamnewInputStream()Opens an InputStream with the matching file system backend of the file. final OutputStreamnewOutputStream()Opens an OutputStream with the matching file system backend of the file. abstract OutputStreamnewOutputStream(boolean append)Opens an OutputStream with the matching file system backend of the file. abstract ExtendedFilegetChildFile(String child)Create a child relative to the abstract pathname using the same file system backend. abstract ExtendedFilegetAbsoluteFile()abstract ExtendedFilegetCanonicalFile()abstract ExtendedFilegetParentFile()abstract Array<ExtendedFile>listFiles()abstract Array<ExtendedFile>listFiles(@Nullable() FilenameFilter filter)abstract Array<ExtendedFile>listFiles(@Nullable() FileFilter filter)-
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setLastModified, setReadOnly, setReadable, setWritable, toPath, toString, toURI, toURL -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
isBlock
abstract boolean isBlock()
-
isCharacter
abstract boolean isCharacter()
-
isSymlink
abstract boolean isSymlink()
-
isNamedPipe
abstract boolean isNamedPipe()
-
isSocket
abstract boolean isSocket()
-
createNewLink
abstract boolean createNewLink(String existing)
Creates a new hard link named by this abstract pathname of an existing fileif and only if a file with this name does not yet exist.
- Parameters:
existing- a path to an existing file.
-
createNewSymlink
abstract boolean createNewSymlink(String target)
Creates a new symbolic link named by this abstract pathname to a target fileif and only if a file with this name does not yet exist.
- Parameters:
target- the target of the symbolic link.
-
newInputStream
@NonNull() abstract InputStream newInputStream()
Opens an InputStream with the matching file system backend of the file.
-
newOutputStream
@NonNull() final OutputStream newOutputStream()
Opens an OutputStream with the matching file system backend of the file.
-
newOutputStream
@NonNull() abstract OutputStream newOutputStream(boolean append)
Opens an OutputStream with the matching file system backend of the file.
-
getChildFile
@NonNull() abstract ExtendedFile getChildFile(String child)
Create a child relative to the abstract pathname using the same file system backend.
-
getAbsoluteFile
@NonNull() abstract ExtendedFile getAbsoluteFile()
-
getCanonicalFile
@NonNull() abstract ExtendedFile getCanonicalFile()
-
getParentFile
@Nullable() abstract ExtendedFile getParentFile()
-
listFiles
@Nullable() abstract Array<ExtendedFile> listFiles()
-
listFiles
@Nullable() abstract Array<ExtendedFile> listFiles(@Nullable() FilenameFilter filter)
-
listFiles
@Nullable() abstract Array<ExtendedFile> listFiles(@Nullable() FileFilter filter)
-
-
-
-