Top Description Fields Constructors Methods
org.apache.derby.impl.io

pack-priv Class DirFile

extends File
implements StorageFile
Class Inheritance
All Implemented Interfaces
org.apache.derby.io.StorageFile
Imports
org.apache.derby.io.StorageFile, .StorageRandomAccessFile, org.apache.derby.shared.common.sanity.SanityManager, java.io.File, .InputStream, .OutputStream, .FileOutputStream, .FileInputStream, .IOException, .FileNotFoundException, .RandomAccessFile, java.nio.channels.AsynchronousCloseException, .FileChannel, .FileLock, .OverlappingFileLockException, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.io.FileUtil, org.apache.derby.iapi.util.InterruptStatus

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

Modifier and TypeField and Description
private FileLock
private FileChannel
private RandomAccessFile
Inherited from java.io.File:
pathSeparatorpathSeparatorCharseparatorseparatorChar

Constructor Summary

AccessConstructor and Description
pack-priv
DirFile(String
The path name.
path
)

Construct a DirFile from a path name.

pack-priv
DirFile(String
The directory part of the path name.
directoryName
,
String
The name of the file within the directory.
fileName
)

Construct a DirFile from a directory name and a file name.

pack-priv
DirFile(DirFile
The directory part of the path name.
directoryName
,
String
The name of the file within the directory.
fileName
)

Construct a DirFile from a directory name and a file name.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the named file or directory is successfully deleted, false if not
deleteAll
()

Implements org.apache.derby.io.StorageFile.deleteAll.

Deletes the named file and, if it is a directory, all the files and directories it contains.

public synchronized int

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.
getExclusiveFileLock
()

Implements org.apache.derby.io.StorageFile.getExclusiveFileLock.

Get an exclusive lock.

public InputStream

Returns:

an input stream suitable for reading from the file.
getInputStream
()

Implements org.apache.derby.io.StorageFile.getInputStream.

Creates an input stream from a file name.

public OutputStream

Returns:

an output stream suitable for writing to the file.
getOutputStream
()

Implements org.apache.derby.io.StorageFile.getOutputStream.

Creates an output stream from a file name.

public OutputStream

Returns:

an output stream suitable for writing to the file.
getOutputStream
(final boolean
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.
append
)

Implements org.apache.derby.io.StorageFile.getOutputStream.

Creates an output stream from a file name.

public StorageFile

Returns:

An StorageFile denoting the parent directory of this StorageFile, if it has a parent, null if it does not have a parent.
getParentDir
()

Implements org.apache.derby.io.StorageFile.getParentDir.

Get the name of the parent directory if this name includes a parent.

public StorageRandomAccessFile

Returns:

an object that can be used for random access to the file.
getRandomAccessFile
(String
"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.
mode
)

Implements org.apache.derby.io.StorageFile.getRandomAccessFile.

Get a random access (read/write) file.

public void
public synchronized void
releaseExclusiveFileLock()

Implements org.apache.derby.io.StorageFile.releaseExclusiveFileLock.

Release the resource associated with an earlier acquired exclusive lock

public boolean

Returns:

true if the rename succeeded, false if not.
renameTo
(StorageFile
the new name.
newName
)

Implements org.apache.derby.io.StorageFile.renameTo.

Rename the file denoted by this name.

Inherited from java.io.File:
canExecutecanReadcanWritecompareTocreateNewFilecreateTempFilecreateTempFiledeletedeleteOnExitequalsexistsgetAbsoluteFilegetAbsolutePathgetCanonicalFilegetCanonicalPathgetFreeSpacegetNamegetParentgetParentFilegetPathgetTotalSpacegetUsableSpacehashCodeisAbsoluteisDirectoryisFileisHiddenlastModifiedlengthlistlistlistFileslistFileslistFileslistRootsmkdirmkdirsrenameTosetExecutablesetExecutablesetLastModifiedsetReadablesetReadablesetReadOnlysetWritablesetWritabletoPathtoStringtoURItoURL

Field Detail

dbLockback to summary
private FileLock dbLock
lockFileChannelback to summary
private FileChannel lockFileChannel
lockFileOpenback to summary
private RandomAccessFile lockFileOpen

Constructor Detail

DirFileback to summary
pack-priv DirFile(String path)

Construct a DirFile from a path name.

Parameters
path:String

The path name.

DirFileback to summary
pack-priv DirFile(String directoryName, String fileName)

Construct a DirFile from a directory name and a file name.

Parameters
directoryName:String

The directory part of the path name.

fileName:String

The name of the file within the directory.

DirFileback to summary
pack-priv DirFile(DirFile directoryName, String fileName)

Construct a DirFile from a directory name and a file name.

Parameters
directoryName:DirFile

The directory part of the path name.

fileName:String

The name of the file within the directory.

Method Detail

deleteAllback to summary
public boolean deleteAll()

Implements org.apache.derby.io.StorageFile.deleteAll.

Deletes the named file and, if it is a directory, all the files and directories it contains.

Returns:boolean

true if the named file or directory is successfully deleted, false if not

getExclusiveFileLockback to summary
public synchronized int getExclusiveFileLock() throws StandardException

Implements org.apache.derby.io.StorageFile.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.

Returns:int

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.

getInputStreamback to summary
public InputStream getInputStream() throws FileNotFoundException

Implements org.apache.derby.io.StorageFile.getInputStream.

Creates an input stream from a file name.

Returns:InputStream

an input stream suitable for reading from the file.

Exceptions
FileNotFoundException:
if the file is not found.
getOutputStreamback to summary
public OutputStream getOutputStream() throws FileNotFoundException

Implements org.apache.derby.io.StorageFile.getOutputStream.

Creates an output stream from a file name.

Returns:OutputStream

an output stream suitable for writing to the file.

Exceptions
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.
getOutputStreamback to summary
public OutputStream getOutputStream(final boolean append) throws FileNotFoundException

Implements org.apache.derby.io.StorageFile.getOutputStream.

Creates an output stream from a file name.

Parameters
append:boolean

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:OutputStream

an output stream suitable for writing to the file.

Exceptions
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.
getParentDirback to summary
public StorageFile getParentDir()

Implements org.apache.derby.io.StorageFile.getParentDir.

Get the name of the parent directory if this name includes a parent.

Returns:StorageFile

An StorageFile denoting the parent directory of this StorageFile, if it has a parent, null if it does not have a parent.

getRandomAccessFileback to summary
public StorageRandomAccessFile getRandomAccessFile(String mode) throws FileNotFoundException

Implements org.apache.derby.io.StorageFile.getRandomAccessFile.

Get a random access (read/write) file.

Parameters
mode:String

"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:StorageRandomAccessFile

an object that can be used for random access to the file.

Exceptions
FileNotFoundException:
if the file exists but is a directory rather than a regular file, or cannot be opened or created for any other reason .
IllegalArgumentException:
if the mode argument is not equal to one of "r", "rw".
limitAccessToOwnerback to summary
public void limitAccessToOwner() throws IOException

Implements org.apache.derby.io.StorageFile.limitAccessToOwner.

Doc from org.apache.derby.io.StorageFile.limitAccessToOwner.

Use 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 property derby.useDefaultFilePermissions is set to true.

releaseExclusiveFileLockback to summary
public synchronized void releaseExclusiveFileLock()

Implements org.apache.derby.io.StorageFile.releaseExclusiveFileLock.

Release the resource associated with an earlier acquired exclusive lock

See Also
getExclusiveFileLock
renameToback to summary
public boolean renameTo(StorageFile newName)

Implements org.apache.derby.io.StorageFile.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.

Parameters
newName:StorageFile

the new name.

Returns:boolean

true if the rename succeeded, false if not.