Class DirFile
java.lang.Object
java.io.File
org.apache.derby.impl.io.DirFile
- All Implemented Interfaces:
Serializable, Comparable<File>, StorageFile
This class provides a disk based implementation of the StorageFile interface. It is used by the
database engine to access persistent data and transaction logs under the directory (default) subsubprotocol.
-
Field Summary
FieldsFields inherited from class File
pathSeparator, pathSeparatorChar, separator, separatorCharFields inherited from interface StorageFile
EXCLUSIVE_FILE_LOCK, EXCLUSIVE_FILE_LOCK_NOT_AVAILABLE, NO_FILE_LOCK_SUPPORT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeletes the named file and, if it is a directory, all the files and directories it contains.intGet an exclusive lock.Creates an input stream from a file name.Creates an output stream from a file name.getOutputStream(boolean append) Creates an output stream from a file name.Get the name of the parent directory if this name includes a parent.getRandomAccessFile(String mode) Get a random access (read/write) file.voidUse when creating a new file.voidRelease the resource associated with an earlier acquired exclusive lockbooleanrenameTo(StorageFile newName) Rename the file denoted by this name.Methods inherited from class File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURLMethods inherited from interface StorageFile
canWrite, createNewFile, delete, exists, getCanonicalPath, getName, getPath, isDirectory, list, mkdir, mkdirs, setReadOnly
-
Field Details
-
lockFileOpen
-
lockFileChannel
-
dbLock
-
-
Constructor Details
-
DirFile
-
DirFile
-
DirFile
-
-
Method Details
-
getParentDir
Get the name of the parent directory if this name includes a parent.- Specified by:
getParentDirin interfaceStorageFile- Returns:
- An StorageFile denoting the parent directory of this StorageFile, if it has a parent, null if it does not have a parent.
-
getOutputStream
Creates an output stream from a file name.- Specified by:
getOutputStreamin interfaceStorageFile- Returns:
- an output stream suitable for writing to the file.
- Throws:
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.
-
getOutputStream
Creates an output stream from a file name.- Specified by:
getOutputStreamin interfaceStorageFile- Parameters:
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.- Returns:
- an output stream suitable for writing to the file.
- Throws:
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.
-
getInputStream
Creates an input stream from a file name.- Specified by:
getInputStreamin interfaceStorageFile- Returns:
- an input stream suitable for reading from the file.
- Throws:
FileNotFoundException- if the file is not found.
-
getExclusiveFileLock
Get an exclusive lock. This is used to ensure that two or more JVMs do not open the same database at the same time.- Specified by:
getExclusiveFileLockin interfaceStorageFile- Returns:
- EXCLUSIVE_FILE_LOCK_NOT_AVAILABLE if the lock cannot be acquired because it is already held.
EXCLUSIVE_FILE_LOCK if the lock was successfully acquired.
NO_FILE_LOCK_SUPPORT if the system does not support exclusive locks. - Throws:
StandardException
-
releaseExclusiveFileLock
public void releaseExclusiveFileLock()Release the resource associated with an earlier acquired exclusive lock- Specified by:
releaseExclusiveFileLockin interfaceStorageFile- See Also:
-
getRandomAccessFile
Get a random access (read/write) file.- Specified by:
getRandomAccessFilein interfaceStorageFile- Parameters:
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. 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 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.- Returns:
- an object that can be used for random access to the file.
- Throws:
IllegalArgumentException- if the mode argument is not equal to one of "r", "rw".FileNotFoundException- if the file exists but is a directory rather than a regular file, or cannot be opened or created for any other reason .- See Also:
-
renameTo
Rename the file denoted by this name. Note that StorageFile objects are immutable. This method renames the underlying file, it does not change this StorageFile object. The StorageFile object denotes the same name as before, however the exists() method will return false after the renameTo method executes successfully.It is not specified whether this method will succeed if a file already exists under the new name.
- Specified by:
renameToin interfaceStorageFile- Parameters:
newName- the new name.- Returns:
- true if the rename succeeded, false if not.
-
deleteAll
public boolean deleteAll()Deletes the named file and, if it is a directory, all the files and directories it contains.- Specified by:
deleteAllin interfaceStorageFile- Returns:
- true if the named file or directory is successfully deleted, false if not
-
limitAccessToOwner
Description copied from interface:StorageFileUse when creating a new file. By default, a file created in an underlying file system, if applicable, will have read and write access for the file owner unless the propertyderby.useDefaultFilePermissionsis set totrue.- Specified by:
limitAccessToOwnerin interfaceStorageFile- Throws:
IOException
-