Package org.h2.test.utils
Class FilePathDebug
java.lang.Object
org.h2.store.fs.FilePath
org.h2.store.fs.FilePathWrapper
org.h2.test.utils.FilePathDebug
A debugging file system that logs all operations.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanWrite()Check if the file is writable.voidCreate a directory (all required parent directories already exist).booleanCreate a new file.createTempFile(String suffix, boolean inTempDir) Create a new temporary file.voiddelete()Delete a file or directory if it exists.booleanexists()Checks if a file exists.getName()Get the file or directory name (the last element of the path).Get the parent directory of a file or directory.intGet the scheme (prefix) for this file provider.booleanCheck if the file name includes a path.booleanCheck if it is a file or a directory.booleanCheck if it is a regular file.booleanisTrace()longGet the last modified date of a filevoidRename 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.static FilePathDebugregister()Register the file system.voidsetPowerOffCount(int count) booleanDisable the ability to write.voidsetTrace(boolean trace) longsize()Get the size of a file in bytesNormalize a file name.Methods inherited from class org.h2.store.fs.FilePathWrapper
getBase, getPath, getPrefix, unwrap, unwrap, wrapMethods inherited from class org.h2.store.fs.FilePath
get, newFileChannelOutputStream, register, toString, unregister
-
Constructor Details
-
FilePathDebug
public FilePathDebug()
-
-
Method Details
-
register
Register the file system.- Returns:
- the instance
-
createDirectory
public void createDirectory()Description copied from class:FilePathCreate a directory (all required parent directories already exist).- Overrides:
createDirectoryin classFilePathWrapper
-
createFile
public boolean createFile()Description copied from class:FilePathCreate a new file.- Overrides:
createFilein classFilePathWrapper- Returns:
- true if creating was successful
-
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
-
exists
public boolean exists()Description copied from class:FilePathChecks if a file exists.- Overrides:
existsin classFilePathWrapper- Returns:
- true if it exists
-
getName
Description copied from class:FilePathGet the file or directory name (the last element of the path). -
lastModified
public long lastModified()Description copied from class:FilePathGet the last modified date of a file- Overrides:
lastModifiedin classFilePathWrapper- Returns:
- the last modified date
-
getParent
Description copied from class:FilePathGet the parent directory of a file or directory.- Overrides:
getParentin classFilePathWrapper- Returns:
- the parent directory name
-
isAbsolute
public boolean isAbsolute()Description copied from class:FilePathCheck if the file name includes a path.- Overrides:
isAbsolutein classFilePathWrapper- Returns:
- if the file name is absolute
-
isDirectory
public boolean isDirectory()Description copied from class:FilePathCheck if it is a file or a directory.- Overrides:
isDirectoryin classFilePathWrapper- Returns:
- true if it is a directory
-
isRegularFile
public boolean isRegularFile()Description copied from class:FilePathCheck if it is a regular file.- Overrides:
isRegularFilein classFilePathWrapper- Returns:
- true if it is a regular file
-
canWrite
public boolean canWrite()Description copied from class:FilePathCheck if the file is writable.- Overrides:
canWritein classFilePathWrapper- Returns:
- if the file is writable
-
setReadOnly
public boolean setReadOnly()Description copied from class:FilePathDisable the ability to write.- Overrides:
setReadOnlyin classFilePathWrapper- Returns:
- true if the call was successful
-
size
public long size()Description copied from class:FilePathGet the size of a file in bytes- Overrides:
sizein classFilePathWrapper- Returns:
- the size in bytes
-
newDirectoryStream
Description copied from class:FilePathList the files and directories in the given directory.- Overrides:
newDirectoryStreamin classFilePathWrapper- Returns:
- the list of fully qualified file names
-
toRealPath
Description copied from class:FilePathNormalize a file name.- Overrides:
toRealPathin classFilePathWrapper- Returns:
- the normalized file name
-
newInputStream
Description copied from class:FilePathCreate an input stream to read from the file.- Overrides:
newInputStreamin classFilePathWrapper- Returns:
- the input stream
- Throws:
IOException- If an I/O error occurs
-
open
Description 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:
IOException- If an I/O error occurs
-
newOutputStream
Description 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:
IOException- If an I/O error occurs
-
moveTo
Description copied from class:FilePathRename a file if this is allowed.- Overrides:
moveToin classFilePathWrapper- Parameters:
newName- 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
-
createTempFile
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:
IOException- on failure
-
setPowerOffCount
public void setPowerOffCount(int count) -
getPowerOffCount
public int getPowerOffCount() -
isTrace
public boolean isTrace() -
setTrace
public void setTrace(boolean trace) -
getScheme
Description copied from class:FilePathGet the scheme (prefix) for this file provider. This is similar tojava.nio.file.spi.FileSystemProvider.getScheme.
-