Package org.h2.store.fs.mem
Class FilePathMem
- java.lang.Object
-
- org.h2.store.fs.FilePath
-
- org.h2.store.fs.mem.FilePathMem
-
- Direct Known Subclasses:
FilePathMemLZF
public class FilePathMem extends FilePath
This file system keeps files fully in memory. There is an option to compress file blocks to save memory.
-
-
Field Summary
Fields Modifier and Type Field Description private static FileMemDataDIRECTORYprivate static java.util.TreeMap<java.lang.String,FileMemData>MEMORY_FILES
-
Constructor Summary
Constructors Constructor Description FilePathMem()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanWrite()Check if the file is writable.(package private) booleancompressed()Whether the file should be compressed.voidcreateDirectory()Create a directory (all required parent directories already exist).booleancreateFile()Create a new file.voiddelete()Delete a file or directory if it exists.booleanexists()Checks if a file exists.protected static java.lang.StringgetCanonicalPath(java.lang.String fileName)Get the canonical path for this file name.private FileMemDatagetMemoryFile()FilePathMemgetParent()Get the parent directory of a file or directory.FilePathMemgetPath(java.lang.String path)Convert a file to a path.java.lang.StringgetScheme()Get the scheme (prefix) for this file provider.booleanisAbsolute()Check if the file name includes a path.booleanisDirectory()Check if it is a file or a directory.private booleanisRoot()longlastModified()Get the last modified date of a filevoidmoveTo(FilePath newName, boolean atomicReplace)Rename a file if this is allowed.java.util.List<FilePath>newDirectoryStream()List the files and directories in the given directory.java.nio.channels.FileChannelopen(java.lang.String mode)Open a random access file object.booleansetReadOnly()Disable the ability to write.longsize()Get the size of a file in bytesFilePathMemtoRealPath()Normalize a file name.-
Methods inherited from class org.h2.store.fs.FilePath
createTempFile, get, getName, newFileChannelOutputStream, newInputStream, newOutputStream, register, toString, unregister, unwrap
-
-
-
-
Field Detail
-
MEMORY_FILES
private static final java.util.TreeMap<java.lang.String,FileMemData> MEMORY_FILES
-
DIRECTORY
private static final FileMemData DIRECTORY
-
-
Method Detail
-
getPath
public FilePathMem getPath(java.lang.String path)
Description copied from class:FilePathConvert 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.
-
size
public long size()
Description copied from class:FilePathGet the size of a file in bytes
-
moveTo
public void moveTo(FilePath newName, boolean atomicReplace)
Description copied from class:FilePathRename a file if this is allowed.
-
createFile
public boolean createFile()
Description copied from class:FilePathCreate a new file.- Specified by:
createFilein classFilePath- Returns:
- true if creating was successful
-
exists
public boolean exists()
Description copied from class:FilePathChecks if a file exists.
-
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.
-
newDirectoryStream
public java.util.List<FilePath> newDirectoryStream()
Description copied from class:FilePathList the files and directories in the given directory.- Specified by:
newDirectoryStreamin classFilePath- Returns:
- the list of fully qualified file names
-
setReadOnly
public boolean setReadOnly()
Description copied from class:FilePathDisable the ability to write.- Specified by:
setReadOnlyin classFilePath- Returns:
- true if the call was successful
-
canWrite
public boolean canWrite()
Description copied from class:FilePathCheck if the file is writable.
-
getParent
public FilePathMem getParent()
Description copied from class:FilePathGet the parent directory of a file or directory.
-
isDirectory
public boolean isDirectory()
Description copied from class:FilePathCheck if it is a file or a directory.- Specified by:
isDirectoryin classFilePath- Returns:
- true if it is a directory
-
isAbsolute
public boolean isAbsolute()
Description copied from class:FilePathCheck if the file name includes a path.- Specified by:
isAbsolutein classFilePath- Returns:
- if the file name is absolute
-
toRealPath
public FilePathMem toRealPath()
Description copied from class:FilePathNormalize a file name.- Specified by:
toRealPathin classFilePath- Returns:
- the normalized file name
-
lastModified
public long lastModified()
Description copied from class:FilePathGet the last modified date of a file- Specified by:
lastModifiedin classFilePath- Returns:
- the last modified date
-
createDirectory
public void createDirectory()
Description copied from class:FilePathCreate a directory (all required parent directories already exist).- Specified by:
createDirectoryin classFilePath
-
open
public java.nio.channels.FileChannel open(java.lang.String mode)
Description copied from class:FilePathOpen a random access file object.
-
getMemoryFile
private FileMemData getMemoryFile()
-
isRoot
private boolean isRoot()
-
getCanonicalPath
protected static java.lang.String getCanonicalPath(java.lang.String fileName)
Get the canonical path for this file name.- Parameters:
fileName- the file name- Returns:
- the canonical path
-
getScheme
public java.lang.String getScheme()
Description copied from class:FilePathGet the scheme (prefix) for this file provider. This is similar tojava.nio.file.spi.FileSystemProvider.getScheme.
-
compressed
boolean compressed()
Whether the file should be compressed.- Returns:
- if it should be compressed.
-
-