Class ExtendedFile
- All Implemented Interfaces:
Serializable,Comparable<File>
- Direct Known Subclasses:
SuFile
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 SuFile, included in the
io module). The developer can get instances of this class with
FileSystemManager.getFile(java.lang.String).
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.
- See Also:
-
Field Summary
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedExtendedFile(File parent, String child) protectedExtendedFile(String pathname) protectedExtendedFile(String parent, String child) protectedExtendedFile(URI uri) -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancreateNewLink(String existing) Creates a new hard link named by this abstract pathname of an existing file if 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 file if and only if a file with this name does not yet exist.abstract ExtendedFileabstract ExtendedFileabstract ExtendedFilegetChildFile(String child) Create a child relative to the abstract pathname using the same file system backend.abstract ExtendedFileabstract booleanisBlock()abstract booleanabstract booleanabstract booleanisSocket()abstract booleanabstract ExtendedFile[]abstract ExtendedFile[]listFiles(FileFilter filter) abstract ExtendedFile[]listFiles(FilenameFilter filter) abstract InputStreamOpens an InputStream with the matching file system backend of the file.final OutputStreamOpens 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.Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsolutePath, getCanonicalPath, getFreeSpace, getName, getParent, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI
-
Constructor Details
-
ExtendedFile
- See Also:
-
ExtendedFile
- See Also:
-
ExtendedFile
- See Also:
-
ExtendedFile
- See Also:
-
-
Method Details
-
isBlock
public abstract boolean isBlock()- Returns:
- true if the abstract pathname denotes a block device.
-
isCharacter
public abstract boolean isCharacter()- Returns:
- true if the abstract pathname denotes a character device.
-
isSymlink
public abstract boolean isSymlink()- Returns:
- true if the abstract pathname denotes a symbolic link.
-
isNamedPipe
public abstract boolean isNamedPipe()- Returns:
- true if the abstract pathname denotes a named pipe (FIFO).
-
isSocket
public abstract boolean isSocket()- Returns:
- true if the abstract pathname denotes a socket file.
-
createNewLink
Creates a new hard link named by this abstract pathname of an existing file if and only if a file with this name does not yet exist.- Parameters:
existing- a path to an existing file.- Returns:
trueif the named file does not exist and was successfully created;falseif the named file already exists.- Throws:
IOException- if an I/O error occurred.
-
createNewSymlink
Creates a new symbolic link named by this abstract pathname to a target file if and only if a file with this name does not yet exist.- Parameters:
target- the target of the symbolic link.- Returns:
trueif the named file does not exist and was successfully created;falseif the named file already exists.- Throws:
IOException- if an I/O error occurred.
-
newInputStream
Opens an InputStream with the matching file system backend of the file.- Throws:
IOException- See Also:
-
newOutputStream
Opens an OutputStream with the matching file system backend of the file.- Throws:
IOException- See Also:
-
newOutputStream
Opens an OutputStream with the matching file system backend of the file.- Throws:
IOException- See Also:
-
getChildFile
Create a child relative to the abstract pathname using the same file system backend.- See Also:
-
getAbsoluteFile
- Overrides:
getAbsoluteFilein classFile
-
getCanonicalFile
- Overrides:
getCanonicalFilein classFile- Throws:
IOException
-
getParentFile
- Overrides:
getParentFilein classFile
-
listFiles
-
listFiles
-
listFiles
-