| java.lang.Object org.apache.derbyTesting.functionTests.util.corruptio.CorruptFile
CorruptFile | class CorruptFile implements StorageFile(Code) | | This class provides proxy implementation of the StorageFile interface. It is
used by CorruptDiskStorageFactory to instrument the database engine
i/o for testing.
See Also: StorageFile |
Method Summary | |
public boolean | canWrite() Determine whether the named file is writable. | public boolean | createNewFile() If the named file does not already exist then create it as an empty
normal file.
The implementation must synchronize with other threads accessing the
same file (in the same or a different process).
If two threads both attempt to create a file with the same name
at the same time then at most one should succeed.
true if this thread's invocation of createNewFile successfully created the named file;false if not, i.e. | public boolean | delete() Deletes the named file or empty directory. | public boolean | deleteAll() Deletes the named file and, if it is a directory, all the files and
directories it contains. | public boolean | exists() Tests whether the named file exists. | public String | getCanonicalPath() Converts this StorageFile into a canonical pathname string. | public synchronized int | getExclusiveFileLock() Get an exclusive lock. | public InputStream | getInputStream() Creates an input stream from a file name.
Parameters: name - The file name. | public String | getName() | public OutputStream | getOutputStream() Creates an output stream from a file name.
Parameters: name - The file name. | public OutputStream | getOutputStream(boolean append) Creates an output stream from a file name.
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. | public StorageFile | getParentDir() Get the name of the parent directory if this name includes a parent. | public String | getPath() Converts this StorageFile into a pathname string. | public StorageRandomAccessFile | getRandomAccessFile(String mode) Get a random access (read/write) file.
Parameters: name - The name of the file. Parameters: mode - "r", "rw", "rws", or "rwd". | protected StorageFile | getRealFileInstance() | public URL | getURL() | public boolean | isDirectory() Tests whether the named file is a directory, or not. | public long | length() Returns the length of the named file if it is not a directory. | public String[] | list() Get the names of all files and sub-directories in the directory named
by this path name.
This method is only used in a writable database.
An array of the names of the files and directories in thisdirectory denoted by this abstract pathname. | public boolean | mkdir() Creates the named directory. | public boolean | mkdirs() Creates the named directory, and all nonexistent parent directories. | public synchronized void | releaseExclusiveFileLock() | public boolean | renameTo(StorageFile newName) Rename the file denoted by this name. | public boolean | setReadOnly() Make the named file or directory read-only. |
canWrite | public boolean canWrite()(Code) | | Determine whether the named file is writable.
true if the file exists and is writable, false if not. |
createNewFile | public boolean createNewFile() throws IOException(Code) | | If the named file does not already exist then create it as an empty
normal file.
The implementation must synchronize with other threads accessing the
same file (in the same or a different process).
If two threads both attempt to create a file with the same name
at the same time then at most one should succeed.
true if this thread's invocation of createNewFile successfully created the named file;false if not, i.e. false if the named file already exists or if another concurrent thread created it. exception: IOException - - If the directory does not exist or some other I/O error occurred |
delete | public boolean delete()(Code) | | Deletes the named file or empty directory.
This method does not delete non-empty directories.
true if the named file or directory is successfully deleted, false if not |
deleteAll | public boolean deleteAll()(Code) | | Deletes the named file and, if it is a directory, all the files and
directories it contains.
true if the named file or directory is successfully deleted, false if not |
exists | public boolean exists()(Code) | | Tests whether the named file exists.
true if the named file exists, false if not. |
getCanonicalPath | public String getCanonicalPath() throws IOException(Code) | | Converts this StorageFile into a canonical pathname string.
The form of the canonical path is system dependent.
The pathname as a string. exception: IOException - if an I/O error occurred while finding the canonical name |
getExclusiveFileLock | public synchronized int getExclusiveFileLock()(Code) | | Get an exclusive lock.
This is used to ensure that two or more JVMs do not open the same
database at the same time.
Parameters: lockFile - The name of the lock. In a file system implementation itwill be the name of a lock file. 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.
|
getName | public String getName()(Code) | | The last segment in the path name, "" if the path name sequence is empty. |
getOutputStream | public OutputStream getOutputStream() throws FileNotFoundException(Code) | | Creates an output stream from a file name.
Parameters: name - The file name. an output stream suitable for writing to the file. exception: FileNotFoundException - if the file exists but is a directoryrather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason. |
getOutputStream | public OutputStream getOutputStream(boolean append) throws FileNotFoundException(Code) | | Creates an output stream from a file name.
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. an output stream suitable for writing to the file. exception: 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. |
getParentDir | public StorageFile getParentDir()(Code) | | Get the name of the parent directory if this name includes a parent.
An StorageFile denoting the parent directory of this StorageFile,if it has a parent, null if it does not have a parent. |
getPath | public String getPath()(Code) | | Converts this StorageFile into a pathname string.
The character returned by StorageFactory.getSeparator()
is used to separate the directory and file names in the sequence.
The returned path may include the database directory.
Therefore it cannot be directly used to make an StorageFile
equivalent to this one.
The pathname as a string. See Also: StorageFactory.getSeparator |
getRandomAccessFile | public StorageRandomAccessFile getRandomAccessFile(String mode) throws FileNotFoundException(Code) | | Get a random access (read/write) file.
Parameters: name - The name of the file. Parameters: mode - "r", "rw", "rws", or "rwd". The "rws" and "rwd" modes specifythat 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"). Howeverthe 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. an object that can be used for random access to the file. exception: IllegalArgumentException - if the mode argument is not equal toone of "r", "rw". exception: FileNotFoundException - if the file exists but is a directoryrather than a regular file, or cannotbe opened or created for any other reason . |
getRealFileInstance | protected StorageFile getRealFileInstance()(Code) | | retuns the real file handle that is used to delegate the calls
|
isDirectory | public boolean isDirectory()(Code) | | Tests whether the named file is a directory, or not.
This is only called in writable storage factories.
true if named file exists and is a directory, false if not.The return value is undefined if the storage is read-only. |
length | public long length()(Code) | | Returns the length of the named file if it is not a directory.
The return value is not specified if the file is a directory.
The length, in bytes, of the named file if it exists and is not a directory, 0 if the file does not exist, or any value if the named file is a directory. |
list | public String[] list()(Code) | | Get the names of all files and sub-directories in the directory named
by this path name.
This method is only used in a writable database.
An array of the names of the files and directories in thisdirectory denoted by this abstract pathname. The returned array will have length 0 if this directory is empty. Returns null if this StorageFile is not a directory, or if an I/O error occurs.The return value is undefined if the database is read-only. |
mkdir | public boolean mkdir()(Code) | | Creates the named directory.
true if the directory was created; false if not. |
mkdirs | public boolean mkdirs()(Code) | | Creates the named directory, and all nonexistent parent directories.
true if the directory was created, false if not |
releaseExclusiveFileLock | public synchronized void releaseExclusiveFileLock()(Code) | | Release the resource associated with an earlier acquired exclusive lock
Parameters: lockFile - the name of the lock file See Also: CorruptFile.getExclusiveFileLock |
renameTo | public boolean renameTo(StorageFile newName)(Code) | | 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 - the new name. true if the rename succeeded, false if not. |
setReadOnly | public boolean setReadOnly()(Code) | | Make the named file or directory read-only.
This interface does not specify whether this also makes the file
undeletable.
true if the named file or directory was made read-only, or it already was read-only; false if not. |
|
|