Top Description Fields Constructors Methods
org.h2.store.fs.disk

public Class FilePathDisk

extends FilePath
Class Inheritance
Imports
java.io.FileNotFoundException, .IOException, .InputStream, .OutputStream, java.net.URI, .URL, java.nio.channels.FileChannel, java.nio.file.AccessDeniedException, .AtomicMoveNotSupportedException, .CopyOption, .DirectoryNotEmptyException, .FileAlreadyExistsException, .FileStore, .FileSystem, .FileSystemNotFoundException, .FileSystems, .Files, .NoSuchFileException, .OpenOption, .Path, .Paths, .StandardCopyOption, .StandardOpenOption, java.nio.file.attribute.DosFileAttributeView, .PosixFileAttributeView, .PosixFilePermission, java.util.ArrayList, .Collections, .HashMap, .HashSet, .List, .Map, java.util.stream.Stream, org.h2.api.ErrorCode, org.h2.engine.SysProperties, org.h2.message.DbException, org.h2.store.fs.FilePath, .FileUtils, org.h2.util.IOUtils

This file system stores files on disk. This is the most common file system.

Field Summary

Modifier and TypeField and Description
private static final String
Inherited from org.h2.store.fs.FilePath:
name

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
canWrite()

Implements abstract org.h2.store.fs.FilePath.canWrite.

Check if the file is writable.

public void
createDirectory()

Implements abstract org.h2.store.fs.FilePath.createDirectory.

Create a directory (all required parent directories already exist).

public boolean
createFile()

Implements abstract org.h2.store.fs.FilePath.createFile.

Create a new file.

public FilePath
createTempFile(String
the suffix
suffix
,
boolean
if the file should be stored in the temporary directory
inTempDir
)

Overrides org.h2.store.fs.FilePath.createTempFile.

Create a new temporary file.

public void
delete()

Implements abstract org.h2.store.fs.FilePath.delete.

Delete a file or directory if it exists.

public boolean
exists()

Implements abstract org.h2.store.fs.FilePath.exists.

Checks if a file exists.

public static String

Returns:

the native file name
expandUserHomeDirectory
(String
the file name
fileName
)

Expand '~' to the user home directory.

pack-priv static void
freeMemoryAndFinalize()

Call the garbage collection and run finalization.

public FilePath
getParent()

Implements abstract org.h2.store.fs.FilePath.getParent.

Get the parent directory of a file or directory.

public FilePathDisk
getPath(String
the path
path
)

Implements abstract org.h2.store.fs.FilePath.getPath.

Convert a file to a path.

public String
getScheme()

Implements abstract org.h2.store.fs.FilePath.getScheme.

Get the scheme (prefix) for this file provider.

public boolean
isAbsolute()

Implements abstract org.h2.store.fs.FilePath.isAbsolute.

Check if the file name includes a path.

public boolean
isDirectory()

Implements abstract org.h2.store.fs.FilePath.isDirectory.

Check if it is a file or a directory.

public boolean
isRegularFile()

Implements abstract org.h2.store.fs.FilePath.isRegularFile.

Check if it is a regular file.

public long
lastModified()

Implements abstract org.h2.store.fs.FilePath.lastModified.

Get the last modified date of a file

public void
moveTo(FilePath
the new fully qualified file name
newName
,
boolean
whether the move should be atomic, and the target file should be replaced if it exists and replacing is possible
atomicReplace
)

Implements abstract org.h2.store.fs.FilePath.moveTo.

Rename a file if this is allowed.

public List<FilePath>
newDirectoryStream()

Implements abstract org.h2.store.fs.FilePath.newDirectoryStream.

List the files and directories in the given directory.

public InputStream
newInputStream()

Overrides org.h2.store.fs.FilePath.newInputStream.

Create an input stream to read from the file.

public OutputStream
newOutputStream(boolean
if true, the file will grow, if false, the file will be truncated first
append
)

Overrides org.h2.store.fs.FilePath.newOutputStream.

Create an output stream to write into the file.

public FileChannel
open(String
the access mode. Supported are r, rw, rws, rwd
mode
)

Implements abstract org.h2.store.fs.FilePath.open.

Open a random access file object.

private static Path
public boolean
setReadOnly()

Implements abstract org.h2.store.fs.FilePath.setReadOnly.

Disable the ability to write.

public long
size()

Implements abstract org.h2.store.fs.FilePath.size.

Get the size of a file in bytes

public FilePathDisk
toRealPath()

Implements abstract org.h2.store.fs.FilePath.toRealPath.

Normalize a file name.

private static Path
protected static String

Returns:

the native file name
translateFileName
(String
the file name
fileName
)

Translate the file name to the native format.

private static void
wait(int i)

Inherited from org.h2.store.fs.FilePath:
getgetNamenewFileChannelOutputStreamregistertoStringunregisterunwrap

Field Detail

CLASSPATH_PREFIXback to summary
private static final String CLASSPATH_PREFIX

Constructor Detail

FilePathDiskback to summary
public FilePathDisk()

Method Detail

canWriteback to summary
public boolean canWrite()

Implements abstract org.h2.store.fs.FilePath.canWrite.

Doc from org.h2.store.fs.FilePath.canWrite.

Check if the file is writable.

Returns:boolean

if the file is writable

Annotations
@Override
createDirectoryback to summary
public void createDirectory()

Implements abstract org.h2.store.fs.FilePath.createDirectory.

Doc from org.h2.store.fs.FilePath.createDirectory.

Create a directory (all required parent directories already exist).

Annotations
@Override
createFileback to summary
public boolean createFile()

Implements abstract org.h2.store.fs.FilePath.createFile.

Doc from org.h2.store.fs.FilePath.createFile.

Create a new file.

Returns:boolean

true if creating was successful

Annotations
@Override
createTempFileback to summary
public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException

Overrides org.h2.store.fs.FilePath.createTempFile.

Doc from org.h2.store.fs.FilePath.createTempFile.

Create a new temporary file.

Parameters
suffix:String

the suffix

inTempDir:boolean

if the file should be stored in the temporary directory

Returns:FilePath

the name of the created file

Annotations
@Override
Exceptions
IOException:
on failure
deleteback to summary
public void delete()

Implements abstract org.h2.store.fs.FilePath.delete.

Doc from org.h2.store.fs.FilePath.delete.

Delete a file or directory if it exists. Directories may only be deleted if they are empty.

Annotations
@Override
existsback to summary
public boolean exists()

Implements abstract org.h2.store.fs.FilePath.exists.

Doc from org.h2.store.fs.FilePath.exists.

Checks if a file exists.

Returns:boolean

true if it exists

Annotations
@Override
expandUserHomeDirectoryback to summary
public static String expandUserHomeDirectory(String fileName)

Expand '~' to the user home directory. It is only be expanded if the '~' stands alone, or is followed by '/' or '\'.

Parameters
fileName:String

the file name

Returns:String

the native file name

freeMemoryAndFinalizeback to summary
pack-priv static void freeMemoryAndFinalize()

Call the garbage collection and run finalization. This close all files that were not closed, and are no longer referenced.

getParentback to summary
public FilePath getParent()

Implements abstract org.h2.store.fs.FilePath.getParent.

Doc from org.h2.store.fs.FilePath.getParent.

Get the parent directory of a file or directory.

Returns:FilePath

the parent directory name

Annotations
@Override
getPathback to summary
public FilePathDisk getPath(String path)

Implements abstract org.h2.store.fs.FilePath.getPath.

Doc from org.h2.store.fs.FilePath.getPath.

Convert a file to a path. This is similar to java.nio.file.spi.FileSystemProvider.getPath, but may return an object even if the scheme doesn't match in case of the default file provider.

Parameters
path:String

the path

Returns:FilePathDisk

the file path object

Annotations
@Override
getSchemeback to summary
public String getScheme()

Implements abstract org.h2.store.fs.FilePath.getScheme.

Doc from org.h2.store.fs.FilePath.getScheme.

Get the scheme (prefix) for this file provider. This is similar to java.nio.file.spi.FileSystemProvider.getScheme.

Returns:String

the scheme

Annotations
@Override
isAbsoluteback to summary
public boolean isAbsolute()

Implements abstract org.h2.store.fs.FilePath.isAbsolute.

Doc from org.h2.store.fs.FilePath.isAbsolute.

Check if the file name includes a path.

Returns:boolean

if the file name is absolute

Annotations
@Override
isDirectoryback to summary
public boolean isDirectory()

Implements abstract org.h2.store.fs.FilePath.isDirectory.

Doc from org.h2.store.fs.FilePath.isDirectory.

Check if it is a file or a directory.

Returns:boolean

true if it is a directory

Annotations
@Override
isRegularFileback to summary
public boolean isRegularFile()

Implements abstract org.h2.store.fs.FilePath.isRegularFile.

Doc from org.h2.store.fs.FilePath.isRegularFile.

Check if it is a regular file.

Returns:boolean

true if it is a regular file

Annotations
@Override
lastModifiedback to summary
public long lastModified()

Implements abstract org.h2.store.fs.FilePath.lastModified.

Doc from org.h2.store.fs.FilePath.lastModified.

Get the last modified date of a file

Returns:long

the last modified date

Annotations
@Override
moveToback to summary
public void moveTo(FilePath newName, boolean atomicReplace)

Implements abstract org.h2.store.fs.FilePath.moveTo.

Doc from org.h2.store.fs.FilePath.moveTo.

Rename a file if this is allowed.

Parameters
newName:FilePath

the new fully qualified file name

atomicReplace:boolean

whether the move should be atomic, and the target file should be replaced if it exists and replacing is possible

Annotations
@Override
newDirectoryStreamback to summary
public List<FilePath> newDirectoryStream()

Implements abstract org.h2.store.fs.FilePath.newDirectoryStream.

Doc from org.h2.store.fs.FilePath.newDirectoryStream.

List the files and directories in the given directory.

Returns:List<FilePath>

the list of fully qualified file names

Annotations
@Override
newInputStreamback to summary
public InputStream newInputStream() throws IOException

Overrides org.h2.store.fs.FilePath.newInputStream.

Doc from org.h2.store.fs.FilePath.newInputStream.

Create an input stream to read from the file.

Returns:InputStream

the input stream

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
newOutputStreamback to summary
public OutputStream newOutputStream(boolean append) throws IOException

Overrides org.h2.store.fs.FilePath.newOutputStream.

Doc from org.h2.store.fs.FilePath.newOutputStream.

Create an output stream to write into the file.

Parameters
append:boolean

if true, the file will grow, if false, the file will be truncated first

Returns:OutputStream

the output stream

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
openback to summary
public FileChannel open(String mode) throws IOException

Implements abstract org.h2.store.fs.FilePath.open.

Doc from org.h2.store.fs.FilePath.open.

Open a random access file object.

Parameters
mode:String

the access mode. Supported are r, rw, rws, rwd

Returns:FileChannel

the file object

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
parentToRealPathback to summary
private static Path parentToRealPath(Path path)
setReadOnlyback to summary
public boolean setReadOnly()

Implements abstract org.h2.store.fs.FilePath.setReadOnly.

Doc from org.h2.store.fs.FilePath.setReadOnly.

Disable the ability to write.

Returns:boolean

true if the call was successful

Annotations
@Override
sizeback to summary
public long size()

Implements abstract org.h2.store.fs.FilePath.size.

Doc from org.h2.store.fs.FilePath.size.

Get the size of a file in bytes

Returns:long

the size in bytes

Annotations
@Override
toRealPathback to summary
public FilePathDisk toRealPath()

Implements abstract org.h2.store.fs.FilePath.toRealPath.

Doc from org.h2.store.fs.FilePath.toRealPath.

Normalize a file name.

Returns:FilePathDisk

the normalized file name

Annotations
@Override
toRealPathback to summary
private static Path toRealPath(Path path)
translateFileNameback to summary
protected static String translateFileName(String fileName)

Translate the file name to the native format. This will replace '\' with '/' and expand the home directory ('~').

Parameters
fileName:String

the file name

Returns:String

the native file name

waitback to summary
private static void wait(int i)