org.h2.test.utils
Class RecordingFileSystem

java.lang.Object
  extended by org.h2.store.fs.FileSystem
      extended by org.h2.store.fs.FileSystemWrapper
          extended by org.h2.test.utils.RecordingFileSystem

public class RecordingFileSystem
extends FileSystemWrapper

A file system that records all write operations and can re-play them.


Field Summary
static java.lang.String PREFIX
          The prefix used for a debugging file system.
 
Constructor Summary
RecordingFileSystem()
           
 
Method Summary
 void copy(java.lang.String source, java.lang.String target)
          Copy a file from one directory to another, or to another file.
 void createDirs(java.lang.String fileName)
          Create all required directories that are required for this file.
 boolean createNewFile(java.lang.String fileName)
          Create a new file.
 java.lang.String createTempFile(java.lang.String prefix, java.lang.String suffix, boolean deleteOnExit, boolean inTempDir)
          Create a new temporary file.
 void delete(java.lang.String fileName)
          Delete a file.
 void deleteRecursive(java.lang.String directory, boolean tryOnly)
          Delete a directory or file and all subdirectories and files.
 java.lang.String getPrefix()
          Get the prefix for this file system.
 boolean isTrace()
           
 FileObject openFileObject(java.lang.String fileName, java.lang.String mode)
          Open a random access file object.
 java.io.OutputStream openFileOutputStream(java.lang.String fileName, boolean append)
          Create an output stream to write into the file.
static void register()
          Register the file system.
 void rename(java.lang.String oldName, java.lang.String newName)
          Rename a file if this is allowed.
static void setRecorder(Recorder recorder)
          Set the recorder class.
 void setTrace(boolean trace)
           
 boolean tryDelete(java.lang.String fileName)
          Try to delete a file.
 
Methods inherited from class org.h2.store.fs.FileSystemWrapper
accepts, canWrite, exists, fileStartsWith, getCanonicalPath, getFileName, getLastModified, getParent, isAbsolute, isDirectory, isReadOnly, length, listFiles, openFileInputStream, setReadOnly, unwrap
 
Methods inherited from class org.h2.store.fs.FileSystem
getInstance, getNextTempFileNamePart, mkdirs, register, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX

public static final java.lang.String PREFIX
The prefix used for a debugging file system.

See Also:
Constant Field Values
Constructor Detail

RecordingFileSystem

public RecordingFileSystem()
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

copy

public void copy(java.lang.String source,
                 java.lang.String target)
Description copied from class: FileSystem
Copy a file from one directory to another, or to another file.

Overrides:
copy in class FileSystemWrapper
Parameters:
source - the name of the original file
target - the file name of the copy

createDirs

public void createDirs(java.lang.String fileName)
Description copied from class: FileSystem
Create all required directories that are required for this file.

Overrides:
createDirs in class FileSystemWrapper
Parameters:
fileName - the file name (not directory name)

createNewFile

public boolean createNewFile(java.lang.String fileName)
Description copied from class: FileSystem
Create a new file.

Overrides:
createNewFile in class FileSystemWrapper
Parameters:
fileName - the file name
Returns:
true if creating was successful

createTempFile

public java.lang.String createTempFile(java.lang.String prefix,
                                       java.lang.String suffix,
                                       boolean deleteOnExit,
                                       boolean inTempDir)
                                throws java.io.IOException
Description copied from class: FileSystem
Create a new temporary file.

Overrides:
createTempFile in class FileSystemWrapper
Parameters:
prefix - the prefix of the file name (including directory name if required)
suffix - the suffix
deleteOnExit - if the file should be deleted when the virtual machine exists
inTempDir - if the file should be stored in the temporary directory
Returns:
the name of the created file
Throws:
java.io.IOException

delete

public void delete(java.lang.String fileName)
Description copied from class: FileSystem
Delete a file.

Overrides:
delete in class FileSystemWrapper
Parameters:
fileName - the file name

deleteRecursive

public void deleteRecursive(java.lang.String directory,
                            boolean tryOnly)
Description copied from class: FileSystem
Delete a directory or file and all subdirectories and files.

Overrides:
deleteRecursive in class FileSystemWrapper
Parameters:
directory - the directory
tryOnly - whether errors should be ignored

openFileObject

public FileObject openFileObject(java.lang.String fileName,
                                 java.lang.String mode)
                          throws java.io.IOException
Description copied from class: FileSystem
Open a random access file object.

Overrides:
openFileObject in class FileSystemWrapper
Parameters:
fileName - the file name
mode - the access mode. Supported are r, rw, rws, rwd
Returns:
the file object
Throws:
java.io.IOException

openFileOutputStream

public java.io.OutputStream openFileOutputStream(java.lang.String fileName,
                                                 boolean append)
Description copied from class: FileSystem
Create an output stream to write into the file.

Overrides:
openFileOutputStream in class FileSystemWrapper
Parameters:
fileName - the file name
append - if true, the file will grow, if false, the file will be truncated first
Returns:
the output stream

rename

public void rename(java.lang.String oldName,
                   java.lang.String newName)
Description copied from class: FileSystem
Rename a file if this is allowed.

Overrides:
rename in class FileSystemWrapper
Parameters:
oldName - the old fully qualified file name
newName - the new fully qualified file name

tryDelete

public boolean tryDelete(java.lang.String fileName)
Description copied from class: FileSystem
Try to delete a file.

Overrides:
tryDelete in class FileSystemWrapper
Parameters:
fileName - the file name
Returns:
true if it could be deleted

getPrefix

public java.lang.String getPrefix()
Description copied from class: FileSystemWrapper
Get the prefix for this file system.

Specified by:
getPrefix in class FileSystemWrapper
Returns:
the prefix

isTrace

public boolean isTrace()

setTrace

public void setTrace(boolean trace)