CPFile
, DirFile
, InputStreamFile
, JarDBFile
, URLFile
, VirtualFile
public interface StorageFile
When used by the database engine all files will be under either the database
directory, specified by the databaseName argument of the StorageFactory.init
method, or under the temporary file
directory returned by the StorageFactory.getTempDir
method. All relative path names are relative to
the database directory.
The database engine will call this interface's methods from its own privilege blocks.
Different threads may operate on the same underlying file at the same time, either through the same or different StorageFile objects. The StiFile implementation must be capable of handling this.
Modifier and Type | Field | Description |
---|---|---|
static int |
EXCLUSIVE_FILE_LOCK |
|
static int |
EXCLUSIVE_FILE_LOCK_NOT_AVAILABLE |
|
static int |
NO_FILE_LOCK_SUPPORT |
Modifier and Type | Method | Description |
---|---|---|
boolean |
canWrite() |
Determine whether the named file is writable.
|
boolean |
createNewFile() |
If the named file does not already exist then create it as an empty normal file.
|
boolean |
delete() |
Deletes the named file or empty directory.
|
boolean |
deleteAll() |
Deletes the named file and, if it is a directory, all the files and directories it contains.
|
boolean |
exists() |
Tests whether the named file exists.
|
java.lang.String |
getCanonicalPath() |
Converts this StorageFile into a canonical pathname string.
|
int |
getExclusiveFileLock() |
Get an exclusive lock with this name.
|
java.io.InputStream |
getInputStream() |
Creates an input stream from a file name.
|
java.lang.String |
getName() |
|
java.io.OutputStream |
getOutputStream() |
Creates an output stream from a file name.
|
java.io.OutputStream |
getOutputStream(boolean append) |
Creates an output stream from a file name.
|
StorageFile |
getParentDir() |
Get the name of the parent directory if this name includes a parent.
|
java.lang.String |
getPath() |
Converts this StorageFile into a pathname string.
|
StorageRandomAccessFile |
getRandomAccessFile(java.lang.String mode) |
Get a random access file.
|
boolean |
isDirectory() |
Tests whether the named file is a directory, or not.
|
void |
limitAccessToOwner() |
Use when creating a new file.
|
java.lang.String[] |
list() |
Get the names of all files and sub-directories in the directory named by this path name.
|
boolean |
mkdir() |
Creates the named directory.
|
boolean |
mkdirs() |
Creates the named directory, and all nonexistent parent directories.
|
void |
releaseExclusiveFileLock() |
Release the resource associated with an earlier acquired exclusive lock
releaseExclusiveFileLock() may delete the file
|
boolean |
renameTo(StorageFile newName) |
Rename the file denoted by this name.
|
boolean |
setReadOnly() |
Make the named file or directory read-only.
|
static final int NO_FILE_LOCK_SUPPORT
static final int EXCLUSIVE_FILE_LOCK
static final int EXCLUSIVE_FILE_LOCK_NOT_AVAILABLE
java.lang.String[] list()
boolean canWrite()
boolean exists()
boolean isDirectory()
boolean delete()
boolean deleteAll()
java.lang.String getPath()
The returned path may include the database directory. Therefore it cannot be directly used to make an StorageFile equivalent to this one.
StorageFactory.getSeparator()
java.lang.String getCanonicalPath() throws java.io.IOException
java.io.IOException
- if an I/O error occurred while finding the canonical namejava.lang.String getName()
boolean createNewFile() throws java.io.IOException
java.io.IOException
- - If the directory does not exist or some other I/O error occurredboolean renameTo(StorageFile newName)
It is not specified whether this method will succeed if a file already exists under the new name.
newName
- the new name.boolean mkdir()
boolean mkdirs()
StorageFile getParentDir()
boolean setReadOnly()
java.io.OutputStream getOutputStream() throws java.io.FileNotFoundException
java.io.FileNotFoundException
- if the file exists but is a directory
rather than a regular file, does not exist but cannot be created, or
cannot be opened for any other reason.java.io.OutputStream getOutputStream(boolean append) throws java.io.FileNotFoundException
append
- If true then data will be appended to the end of the file, if it already exists.
If false and a normal file already exists with this name the file will first be truncated
to zero length.java.io.FileNotFoundException
- if the file exists but is a directory
rather than a regular file, does not exist but cannot be created, or
cannot be opened for any other reason.java.io.InputStream getInputStream() throws java.io.FileNotFoundException
java.io.FileNotFoundException
- if the file is not found.int getExclusiveFileLock() throws StandardException
StandardException
void releaseExclusiveFileLock()
getExclusiveFileLock()
StorageRandomAccessFile getRandomAccessFile(java.lang.String mode) throws java.io.FileNotFoundException
mode
- "r", "rw", "rws", or "rwd". The "rws" and "rwd" modes specify
that the data is to be written to persistent store, consistent with the
java.io.RandomAccessFile class ("synchronized" with the persistent
storage, in the file system meaning of the word "synchronized"). However
the implementation is not required to implement the "rws" or "rwd"
modes. If the "rws" andr "rwd" modes are supported then the supportsRws() method
of the StorageFactory returns true. If supportsRws() returns false then the
implementation may treat "rws" and "rwd" as "rw". It is up to
the user of this interface to call the StorageRandomAccessFile.sync
method if necessary. However, if the "rws" or "rwd" modes are supported and the
RandomAccessFile was opened in "rws" or "rwd" mode then the
implementation of StorageRandomAccessFile.sync need not do anything.java.lang.IllegalArgumentException
- if the mode argument is not equal to one of "r", "rw", "rws", or "rwd".java.io.FileNotFoundException
- if the file exists but is a directory rather than a regular
file, or cannot be opened or created for any other reason .void limitAccessToOwner() throws java.io.IOException
derby.useDefaultFilePermissions
is set to true
.java.io.IOException
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.