Package org.h2.store.fs
Class FilePathWrapper
java.lang.Object
org.h2.store.fs.FilePath
org.h2.store.fs.FilePathWrapper
- Direct Known Subclasses:
FilePathAsync
,FilePathCache
,FilePathEncrypt
,FilePathNioMapped
,FilePathRec
,FilePathRetryOnInterrupt
,FilePathSplit
The base class for wrapping / delegating file systems such as
the split file system.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canWrite()
Check if the file is writable.private FilePathWrapper
void
Create a directory (all required parent directories already exist).boolean
Create a new file.createTempFile
(String suffix, boolean inTempDir) Create a new temporary file.void
delete()
Delete a file or directory if it exists.boolean
exists()
Checks if a file exists.protected FilePath
getBase()
Get the parent directory of a file or directory.Convert a file to a path.protected String
boolean
Check if the file name includes a path.boolean
Check if it is a file or a directory.long
Get the last modified date of a filevoid
Rename a file if this is allowed.List the files and directories in the given directory.Create an input stream to read from the file.newOutputStream
(boolean append) Create an output stream to write into the file.Open a random access file object.boolean
Disable the ability to write.long
size()
Get the size of a file in bytesNormalize a file name.unwrap()
Get the unwrapped file name (without wrapper prefixes if wrapping / delegating file systems are used).protected FilePath
Get the base path for the given wrapped path.Create a wrapped path instance for the given base path.Methods inherited from class org.h2.store.fs.FilePath
get, getName, getScheme, newFileChannelOutputStream, register, toString, unregister
-
Field Details
-
base
-
-
Constructor Details
-
FilePathWrapper
public FilePathWrapper()
-
-
Method Details
-
getPath
Description copied from class:FilePath
Convert a file to a path. This is similar tojava.nio.file.spi.FileSystemProvider.getPath
, but may return an object even if the scheme doesn't match in case of the default file provider. -
wrap
Create a wrapped path instance for the given base path.- Parameters:
base
- the base path- Returns:
- the wrapped path
-
unwrap
Description copied from class:FilePath
Get the unwrapped file name (without wrapper prefixes if wrapping / delegating file systems are used). -
create
-
getPrefix
-
unwrap
Get the base path for the given wrapped path.- Parameters:
path
- the path including the scheme prefix- Returns:
- the base file path
-
getBase
-
canWrite
public boolean canWrite()Description copied from class:FilePath
Check if the file is writable. -
createDirectory
public void createDirectory()Description copied from class:FilePath
Create a directory (all required parent directories already exist).- Specified by:
createDirectory
in classFilePath
-
createFile
public boolean createFile()Description copied from class:FilePath
Create a new file.- Specified by:
createFile
in classFilePath
- Returns:
- true if creating was successful
-
delete
public void delete()Description copied from class:FilePath
Delete a file or directory if it exists. Directories may only be deleted if they are empty. -
exists
public boolean exists()Description copied from class:FilePath
Checks if a file exists. -
getParent
Description copied from class:FilePath
Get the parent directory of a file or directory. -
isAbsolute
public boolean isAbsolute()Description copied from class:FilePath
Check if the file name includes a path.- Specified by:
isAbsolute
in classFilePath
- Returns:
- if the file name is absolute
-
isDirectory
public boolean isDirectory()Description copied from class:FilePath
Check if it is a file or a directory.- Specified by:
isDirectory
in classFilePath
- Returns:
- true if it is a directory
-
lastModified
public long lastModified()Description copied from class:FilePath
Get the last modified date of a file- Specified by:
lastModified
in classFilePath
- Returns:
- the last modified date
-
toRealPath
Description copied from class:FilePath
Normalize a file name.- Specified by:
toRealPath
in classFilePath
- Returns:
- the normalized file name
-
newDirectoryStream
Description copied from class:FilePath
List the files and directories in the given directory.- Specified by:
newDirectoryStream
in classFilePath
- Returns:
- the list of fully qualified file names
-
moveTo
Description copied from class:FilePath
Rename a file if this is allowed. -
newInputStream
Description copied from class:FilePath
Create an input stream to read from the file.- Overrides:
newInputStream
in classFilePath
- Returns:
- the input stream
- Throws:
IOException
- If an I/O error occurs
-
newOutputStream
Description copied from class:FilePath
Create an output stream to write into the file.- Overrides:
newOutputStream
in classFilePath
- Parameters:
append
- if true, the file will grow, if false, the file will be truncated first- Returns:
- the output stream
- Throws:
IOException
- If an I/O error occurs
-
open
Description copied from class:FilePath
Open a random access file object.- Specified by:
open
in classFilePath
- Parameters:
mode
- the access mode. Supported are r, rw, rws, rwd- Returns:
- the file object
- Throws:
IOException
- If an I/O error occurs
-
setReadOnly
public boolean setReadOnly()Description copied from class:FilePath
Disable the ability to write.- Specified by:
setReadOnly
in classFilePath
- Returns:
- true if the call was successful
-
size
public long size()Description copied from class:FilePath
Get the size of a file in bytes -
createTempFile
Description copied from class:FilePath
Create a new temporary file.- Overrides:
createTempFile
in classFilePath
- Parameters:
suffix
- the suffixinTempDir
- if the file should be stored in the temporary directory- Returns:
- the name of the created file
- Throws:
IOException
- on failure
-