| Modifier and Type | Field and Description |
|---|---|
| private final FileChannel | |
| public static final int | BLOCK_SIZE
The block size. |
| pack-priv static final int | BLOCK_SIZE_MASK
The block size bit mask. |
| private byte[] | |
| private static final int | HASH_ITERATIONS
The number of iterations. |
| private static final byte[] | |
| pack-priv static final int | HEADER_LENGTH
The length of the file header. |
| private final String | |
| private static final int | SALT_LENGTH
The length of the salt, in bytes. |
| private static final int | |
| private volatile long | size
The current file size, from a user perspective. |
| private FileEncrypt | |
| private volatile XTS |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private synchronized XTS | |
| public void | force(boolean
If metaData)true then this method is required to force changes
to both the file's content and metadata to be written to
storage; otherwise, it need only force content changes to be
writtenOverrides org. Forces any updates to this channel's file to be written to the storage device that contains it. |
| protected void | |
| protected void | implTruncate(long
the new size newSize)Implements abstract org. The truncate implementation. |
| private XTS | |
| public int | read(ByteBuffer
The buffer into which bytes are to be transferred dst, long The file position at which the transfer is to begin;
must be non-negative position)Overrides org. Reads a sequence of bytes from this channel into the given buffer, starting at the given file position. |
| private static void | |
| private void | |
| public long | size()
Implements abstract java. Implements java. Returns the current size of this channel's file. |
| public String | |
| public FileLock | tryLock(long
The position at which the locked region is to start; must be
non-negative position, long The size of the locked region; must be non-negative, and the sum
size, boolean position + size must be non-negative.
A value of zero means to lock all bytes from the specified
starting position to the end of the file, regardless of whether
the file is subsequently extended or truncatedtrue to request a shared lock,
false to request an exclusive lockOverrides org. Attempts to acquire a lock on the given region of this channel's file. |
| public int | write(ByteBuffer
The buffer from which bytes are to be transferred src, long The file position at which the transfer is to begin;
must be non-negative position)Overrides org. Writes a sequence of bytes to this channel from the given buffer, starting at the given file position. |
| private static void | |
| private void |
| base | back to summary |
|---|---|
| private final FileChannel base | |
| BLOCK_SIZE | back to summary |
|---|---|
| public static final int BLOCK_SIZE The block size. | |
| BLOCK_SIZE_MASK | back to summary |
|---|---|
| pack-priv static final int BLOCK_SIZE_MASK The block size bit mask. | |
| encryptionKey | back to summary |
|---|---|
| private byte[] encryptionKey | |
| HASH_ITERATIONS | back to summary |
|---|---|
| private static final int HASH_ITERATIONS The number of iterations. It is relatively low; a higher value would slow down opening files on Android too much. | |
| HEADER | back to summary |
|---|---|
| private static final byte[] HEADER | |
| HEADER_LENGTH | back to summary |
|---|---|
| pack-priv static final int HEADER_LENGTH The length of the file header. Using a smaller header is possible, but would mean reads and writes are not aligned to the block size. | |
| name | back to summary |
|---|---|
| private final String name | |
| SALT_LENGTH | back to summary |
|---|---|
| private static final int SALT_LENGTH The length of the salt, in bytes. | |
| SALT_POS | back to summary |
|---|---|
| private static final int SALT_POS | |
| size | back to summary |
|---|---|
| private volatile long size The current file size, from a user perspective. | |
| source | back to summary |
|---|---|
| private FileEncrypt source | |
| xts | back to summary |
|---|---|
| private volatile XTS xts | |
| FileEncrypt | back to summary |
|---|---|
| public FileEncrypt(String name, byte[] encryptionKey, FileChannel base) | |
| FileEncrypt | back to summary |
|---|---|
| public FileEncrypt(String name, FileEncrypt source, FileChannel base) | |
| createXTS | back to summary |
|---|---|
| private synchronized XTS createXTS() throws IOException | |
| force | back to summary |
|---|---|
| public void force(boolean metaData) throws IOException Overrides org. Doc from java. Forces any updates to this channel's file to be written to the storage device that contains it. If this channel's file resides on a local storage device then when this method returns it is guaranteed that all changes made to the file since this channel was created, or since this method was last invoked, will have been written to that device. This is useful for ensuring that critical information is not lost in the event of a system crash. If the file does not reside on a local device then no such guarantee is made. The Invoking this method may cause an I/O operation to occur even if the channel was only opened for reading. Some operating systems, for example, maintain a last-access time as part of a file's metadata, and this time is updated whenever the file is read. Whether or not this is actually done is system-dependent and is therefore unspecified. This method is only guaranteed to force changes that were made to
this channel's file via the methods defined in this class, or the methods
defined by
| |
| implCloseChannel | back to summary |
|---|---|
| protected void implCloseChannel() throws IOException Overrides org. Doc from java. Closes this channel. This method is invoked by the An implementation of this method must arrange for any other thread that is blocked in an I/O operation upon this channel to return immediately, either by throwing an exception or by returning normally.
| |
| implTruncate | back to summary |
|---|---|
| protected void implTruncate(long newSize) throws IOException Implements abstract org. Doc from org. The truncate implementation.
| |
| init | back to summary |
|---|---|
| private XTS init() throws IOException | |
| read | back to summary |
|---|---|
| public int read(ByteBuffer dst, long position) throws IOException Overrides org. Doc from java. Reads a sequence of bytes from this channel into the given buffer, starting at the given file position. This method works in the same manner as the
| |
| readFully | back to summary |
|---|---|
| private static void readFully(FileChannel file, long pos, ByteBuffer dst) throws IOException | |
| readInternal | back to summary |
|---|---|
| private void readInternal(ByteBuffer dst, long position, int len, XTS xts) throws IOException | |
| size | back to summary |
|---|---|
| public long size() throws IOException Implements abstract java. Implements java. Doc from java. Returns the current size of this channel's file.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| tryLock | back to summary |
|---|---|
| public FileLock tryLock(long position, long size, boolean shared) throws IOException Overrides org. Doc from java. Attempts to acquire a lock on the given region of this channel's file. This method does not block. An invocation always returns
immediately, either having acquired a lock on the requested region or
having failed to do so. If it fails to acquire a lock because an
overlapping lock is held by another program then it returns
The region specified by the Some operating systems do not support shared locks, in which case a
request for a shared lock is automatically converted into a request for
an exclusive lock. Whether the newly-acquired lock is shared or
exclusive may be tested by invoking the resulting lock object's File locks are held on behalf of the entire Java virtual machine. They are not suitable for controlling access to a file by multiple threads within the same virtual machine.
| |
| write | back to summary |
|---|---|
| public int write(ByteBuffer src, long position) throws IOException Overrides org. Doc from java. Writes a sequence of bytes to this channel from the given buffer, starting at the given file position. This method works in the same manner as the If the file is open in append mode, then the effect of invoking this method is unspecified.
| |
| writeFully | back to summary |
|---|---|
| private static void writeFully(FileChannel file, long pos, ByteBuffer src) throws IOException | |
| writeInternal | back to summary |
|---|---|
| private void writeInternal(ByteBuffer src, long position, int len, XTS xts) throws IOException | |