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 File
s. 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
ModifierConstructorDescriptionprotected
ExtendedFile
(File parent, String child) protected
ExtendedFile
(String pathname) protected
ExtendedFile
(String parent, String child) protected
ExtendedFile
(URI uri) -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
createNewLink
(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 boolean
createNewSymlink
(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 ExtendedFile
abstract ExtendedFile
abstract ExtendedFile
getChildFile
(String child) Create a child relative to the abstract pathname using the same file system backend.abstract ExtendedFile
abstract boolean
isBlock()
abstract boolean
abstract boolean
abstract boolean
isSocket()
abstract boolean
abstract ExtendedFile[]
abstract ExtendedFile[]
listFiles
(FileFilter filter) abstract ExtendedFile[]
listFiles
(FilenameFilter filter) abstract InputStream
Opens an InputStream with the matching file system backend of the file.final OutputStream
Opens an OutputStream with the matching file system backend of the file.abstract OutputStream
newOutputStream
(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:
true
if the named file does not exist and was successfully created;false
if 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:
true
if the named file does not exist and was successfully created;false
if 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:
getAbsoluteFile
in classFile
-
getCanonicalFile
- Overrides:
getCanonicalFile
in classFile
- Throws:
IOException
-
getParentFile
- Overrides:
getParentFile
in classFile
-
listFiles
-
listFiles
-
listFiles
-