public class FileBucket extends BaseFileBucket implements Bucket, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected boolean |
createFileOnly |
protected boolean |
deleteOnExit |
protected boolean |
deleteOnFree |
protected java.io.File |
file |
static int |
MAGIC |
protected boolean |
readOnly |
fileRestartCounter, tempDir
Modifier | Constructor and Description |
---|---|
protected |
FileBucket() |
protected |
FileBucket(java.io.DataInputStream dis) |
|
FileBucket(java.io.File file,
boolean readOnly,
boolean createFileOnly,
boolean deleteOnExit,
boolean deleteOnFree)
Creates a new FileBucket.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
createFileOnly()
If true, we will fail if the file already exist.
|
RandomAccessBucket |
createShadow()
Create a shallow read-only copy of this bucket, using different
objects but using the same external storage.
|
protected boolean |
deleteOnExit() |
protected boolean |
deleteOnFree() |
boolean |
equals(java.lang.Object obj) |
java.io.File |
getFile()
Returns the file object this buckets data is kept in.
|
int |
hashCode() |
boolean |
isReadOnly()
Is the bucket read-only?
|
void |
onResume(ClientContext context)
Called after restarting.
|
void |
setReadOnly()
Make the bucket read-only.
|
void |
storeTo(java.io.DataOutputStream dos)
Write enough data to reconstruct the Bucket, or throw UnsupportedOperationException.
|
protected boolean |
tempFileAlreadyExists()
If true, then the file is temporary and must already exist, so we will just open it.
|
deleteFile, free, free, getInputStream, getInputStreamUnbuffered, getName, getOutputStream, getOutputStreamUnbuffered, getPersistentTempID, getTempDir, getTempfile, setDeleteOnExit, setTempDir, size, split, toRandomAccessBuffer, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
free, getInputStream, getInputStreamUnbuffered, getName, getOutputStream, getOutputStreamUnbuffered, size
protected final java.io.File file
protected boolean readOnly
protected boolean deleteOnFree
protected final boolean deleteOnExit
protected final boolean createFileOnly
public static final int MAGIC
public FileBucket(java.io.File file, boolean readOnly, boolean createFileOnly, boolean deleteOnExit, boolean deleteOnFree)
file
- The File to read and write to.readOnly
- If true, any attempt to write to the bucket will result in an IOException.
Can be set later. Irreversible. @see isReadOnly(), setReadOnly()createFileOnly
- If true, create the file if it doesn't exist, but if it does exist,
throw a FileExistsException on any write operation. This is safe against symlink attacks
because we write to a temp file and then rename. It is technically possible that the rename
will clobber an existing file if there is a race condition, but since it will not write over
a symlink this is probably not dangerous. User-supplied filenames should in any case be
restricted by higher levels.deleteOnExit
- If true, delete the file on a clean exit of the JVM. Irreversible - use with care!deleteOnFree
- If true, delete the file on finalization. Reversible.protected FileBucket()
protected FileBucket(java.io.DataInputStream dis) throws java.io.IOException, StorageFormatException
java.io.IOException
StorageFormatException
public java.io.File getFile()
getFile
in class BaseFileBucket
public boolean isReadOnly()
Bucket
isReadOnly
in interface Bucket
public void setReadOnly()
Bucket
setReadOnly
in interface Bucket
protected boolean createFileOnly()
BaseFileBucket
createFileOnly
in class BaseFileBucket
protected boolean deleteOnExit()
deleteOnExit
in class BaseFileBucket
protected boolean deleteOnFree()
deleteOnFree
in class BaseFileBucket
public RandomAccessBucket createShadow()
Bucket
createShadow
in interface Bucket
createShadow
in interface RandomAccessBucket
public void onResume(ClientContext context) throws ResumeFailedException
Bucket
onResume
in interface Bucket
onResume
in class BaseFileBucket
context
- All the necessary runtime support will be on this object.ResumeFailedException
protected boolean tempFileAlreadyExists()
BaseFileBucket
tempFileAlreadyExists
in class BaseFileBucket
public void storeTo(java.io.DataOutputStream dos) throws java.io.IOException
Bucket
storeTo
in interface Bucket
storeTo
in class BaseFileBucket
java.io.IOException
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object