Package org.h2.store.fs.split
Class FilePathSplit
- java.lang.Object
-
- org.h2.store.fs.FilePath
-
- org.h2.store.fs.FilePathWrapper
-
- org.h2.store.fs.split.FilePathSplit
-
public class FilePathSplit extends FilePathWrapper
A file system that may split files into multiple smaller files. (required for a FAT32 because it only support files up to 2 GB).
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
PART_SUFFIX
-
Constructor Summary
Constructors Constructor Description FilePathSplit()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
closeAndThrow(int id, java.nio.channels.FileChannel[] array, java.nio.channels.FileChannel o, long maxLength)
void
delete()
Delete a file or directory if it exists.(package private) FilePath
getBase(int id)
Get the file name of a part file.private long
getDefaultMaxLength()
private java.lang.String
getName(int id)
protected java.lang.String
getPrefix()
java.lang.String
getScheme()
Get the scheme (prefix) for this file provider.long
lastModified()
Get the last modified date of a filevoid
moveTo(FilePath path, boolean atomicReplace)
Rename a file if this is allowed.java.util.ArrayList<FilePath>
newDirectoryStream()
List the files and directories in the given directory.java.io.InputStream
newInputStream()
Create an input stream to read from the file.java.io.OutputStream
newOutputStream(boolean append)
Create an output stream to write into the file.java.nio.channels.FileChannel
open(java.lang.String mode)
Open a random access file object.private java.lang.String[]
parse(java.lang.String fileName)
Split the file name into size and base file name.boolean
setReadOnly()
Disable the ability to write.long
size()
Get the size of a file in bytesFilePath
unwrap(java.lang.String fileName)
Get the base path for the given wrapped path.-
Methods inherited from class org.h2.store.fs.FilePathWrapper
canWrite, createDirectory, createFile, createTempFile, exists, getBase, getParent, getPath, isAbsolute, isDirectory, toRealPath, unwrap, wrap
-
Methods inherited from class org.h2.store.fs.FilePath
get, getName, newFileChannelOutputStream, register, toString, unregister
-
-
-
-
Field Detail
-
PART_SUFFIX
private static final java.lang.String PART_SUFFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPrefix
protected java.lang.String getPrefix()
- Overrides:
getPrefix
in classFilePathWrapper
-
unwrap
public FilePath unwrap(java.lang.String fileName)
Description copied from class:FilePathWrapper
Get the base path for the given wrapped path.- Overrides:
unwrap
in classFilePathWrapper
- Parameters:
fileName
- the path including the scheme prefix- Returns:
- the base file path
-
setReadOnly
public boolean setReadOnly()
Description copied from class:FilePath
Disable the ability to write.- Overrides:
setReadOnly
in classFilePathWrapper
- Returns:
- true if the call 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.- Overrides:
delete
in classFilePathWrapper
-
lastModified
public long lastModified()
Description copied from class:FilePath
Get the last modified date of a file- Overrides:
lastModified
in classFilePathWrapper
- Returns:
- the last modified date
-
size
public long size()
Description copied from class:FilePath
Get the size of a file in bytes- Overrides:
size
in classFilePathWrapper
- Returns:
- the size in bytes
-
newDirectoryStream
public java.util.ArrayList<FilePath> newDirectoryStream()
Description copied from class:FilePath
List the files and directories in the given directory.- Overrides:
newDirectoryStream
in classFilePathWrapper
- Returns:
- the list of fully qualified file names
-
newInputStream
public java.io.InputStream newInputStream() throws java.io.IOException
Description copied from class:FilePath
Create an input stream to read from the file.- Overrides:
newInputStream
in classFilePathWrapper
- Returns:
- the input stream
- Throws:
java.io.IOException
- If an I/O error occurs
-
open
public java.nio.channels.FileChannel open(java.lang.String mode) throws java.io.IOException
Description copied from class:FilePath
Open a random access file object.- Overrides:
open
in classFilePathWrapper
- Parameters:
mode
- the access mode. Supported are r, rw, rws, rwd- Returns:
- the file object
- Throws:
java.io.IOException
- If an I/O error occurs
-
getDefaultMaxLength
private long getDefaultMaxLength()
-
closeAndThrow
private void closeAndThrow(int id, java.nio.channels.FileChannel[] array, java.nio.channels.FileChannel o, long maxLength) throws java.io.IOException
- Throws:
java.io.IOException
-
newOutputStream
public java.io.OutputStream newOutputStream(boolean append) throws java.io.IOException
Description copied from class:FilePath
Create an output stream to write into the file.- Overrides:
newOutputStream
in classFilePathWrapper
- Parameters:
append
- if true, the file will grow, if false, the file will be truncated first- Returns:
- the output stream
- Throws:
java.io.IOException
- If an I/O error occurs
-
moveTo
public void moveTo(FilePath path, boolean atomicReplace)
Description copied from class:FilePath
Rename a file if this is allowed.- Overrides:
moveTo
in classFilePathWrapper
- Parameters:
path
- the new fully qualified file nameatomicReplace
- whether the move should be atomic, and the target file should be replaced if it exists and replacing is possible
-
parse
private java.lang.String[] parse(java.lang.String fileName)
Split the file name into size and base file name.- Parameters:
fileName
- the file name- Returns:
- an array with size and file name
-
getBase
FilePath getBase(int id)
Get the file name of a part file.- Parameters:
id
- the part id- Returns:
- the file name including the part id
-
getName
private java.lang.String getName(int id)
-
-