Package org.h2.store.fs.rec
Class FilePathRec
- java.lang.Object
-
- org.h2.store.fs.FilePath
-
- org.h2.store.fs.FilePathWrapper
-
- org.h2.store.fs.rec.FilePathRec
-
public class FilePathRec extends FilePathWrapper
A file system that records all write operations and can re-play them.
-
-
Constructor Summary
Constructors Constructor Description FilePathRec()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancreateFile()Create a new file.FilePathcreateTempFile(java.lang.String suffix, boolean inTempDir)Create a new temporary file.voiddelete()Delete a file or directory if it exists.java.lang.StringgetScheme()Get the prefix for this file system.booleanisTrace()(package private) voidlog(int op, java.lang.String fileName)Log the operation.(package private) voidlog(int op, java.lang.String fileName, byte[] data, long x)Log the operation.voidmoveTo(FilePath newPath, boolean atomicReplace)Rename a file if this is allowed.java.io.OutputStreamnewOutputStream(boolean append)Create an output stream to write into the file.java.nio.channels.FileChannelopen(java.lang.String mode)Open a random access file object.static voidregister()Register the file system.static voidsetRecorder(Recorder recorder)Set the recorder class.voidsetTrace(boolean trace)-
Methods inherited from class org.h2.store.fs.FilePathWrapper
canWrite, createDirectory, exists, getBase, getParent, getPath, getPrefix, isAbsolute, isDirectory, lastModified, newDirectoryStream, newInputStream, setReadOnly, size, toRealPath, unwrap, unwrap, wrap
-
Methods inherited from class org.h2.store.fs.FilePath
get, getName, newFileChannelOutputStream, register, toString, unregister
-
-
-
-
Field Detail
-
INSTANCE
private static final FilePathRec INSTANCE
-
recorder
private static Recorder recorder
-
trace
private boolean trace
-
-
Method Detail
-
register
public static void register()
Register the file system.
-
setRecorder
public static void setRecorder(Recorder recorder)
Set the recorder class.- Parameters:
recorder- the recorder
-
createFile
public boolean createFile()
Description copied from class:FilePathCreate a new file.- Overrides:
createFilein classFilePathWrapper- Returns:
- true if creating was successful
-
createTempFile
public FilePath createTempFile(java.lang.String suffix, boolean inTempDir) throws java.io.IOException
Description copied from class:FilePathCreate a new temporary file.- Overrides:
createTempFilein classFilePathWrapper- Parameters:
suffix- the suffixinTempDir- if the file should be stored in the temporary directory- Returns:
- the name of the created file
- Throws:
java.io.IOException- on failure
-
delete
public void delete()
Description copied from class:FilePathDelete a file or directory if it exists. Directories may only be deleted if they are empty.- Overrides:
deletein classFilePathWrapper
-
open
public java.nio.channels.FileChannel open(java.lang.String mode) throws java.io.IOExceptionDescription copied from class:FilePathOpen a random access file object.- Overrides:
openin 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
-
newOutputStream
public java.io.OutputStream newOutputStream(boolean append) throws java.io.IOExceptionDescription copied from class:FilePathCreate an output stream to write into the file.- Overrides:
newOutputStreamin 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 newPath, boolean atomicReplace)
Description copied from class:FilePathRename a file if this is allowed.- Overrides:
moveToin classFilePathWrapper- Parameters:
newPath- 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
-
isTrace
public boolean isTrace()
-
setTrace
public void setTrace(boolean trace)
-
log
void log(int op, java.lang.String fileName)Log the operation.- Parameters:
op- the operationfileName- the file name(s)
-
log
void log(int op, java.lang.String fileName, byte[] data, long x)Log the operation.- Parameters:
op- the operationfileName- the file namedata- the data or nullx- the value or 0
-
-