OSFileSystempublic class OSFileSystem extends OSComponent implements IFileSystemThis is the portable implementation of the file system interface. |
Constructors Summary |
---|
public OSFileSystem()
super();
|
Methods Summary |
---|
public void | close(int fileDescriptor)
int rc = closeImpl(fileDescriptor);
if (rc == -1) {
throw new IOException();
}
| private native int | closeImpl(int fileDescriptor)
| public void | fflush(int fileDescriptor, boolean metadata)
int result = fflushImpl(fileDescriptor, metadata);
if (result == -1) {
throw new IOException();
}
| private native int | fflushImpl(int fd, boolean metadata)
| public native int | getAllocGranularity()Returns the granularity for virtual memory allocation.
Note that this value for Windows differs from the one for the
page size (64K and 4K respectively).
| public native int | ioctlAvailable(int fileDescriptor)
| public boolean | lock(int fileDescriptor, long start, long length, int type, boolean waitFlag)
// Validate arguments
validateLockArgs(type, start, length);
int result = lockImpl(fileDescriptor, start, length, type, waitFlag);
return result != -1;
| private native int | lockImpl(int fileDescriptor, long start, long length, int type, boolean wait)
| public int | open(byte[] fileName, int mode)
if (fileName == null) {
throw new NullPointerException();
}
int handler = openImpl(fileName, mode);
if (handler < 0) {
throw new FileNotFoundException(new String(fileName));
}
return handler;
| private native int | openImpl(byte[] fileName, int mode)
| public long | read(int fileDescriptor, byte[] bytes, int offset, int length)
if (bytes == null) {
throw new NullPointerException();
}
long bytesRead = readImpl(fileDescriptor, bytes, offset, length);
if (bytesRead < -1) {
throw new IOException();
}
return bytesRead;
| public long | readDirect(int fileDescriptor, int address, int offset, int length)
long bytesRead = readDirectImpl(fileDescriptor, address, offset, length);
if (bytesRead < -1) {
throw new IOException();
}
return bytesRead;
| private native long | readDirectImpl(int fileDescriptor, int address, int offset, int length)
| private native long | readImpl(int fileDescriptor, byte[] bytes, int offset, int length)
| public long | readv(int fileDescriptor, int[] addresses, int[] offsets, int[] lengths, int size)
long bytesRead = readvImpl(fileDescriptor, addresses, offsets, lengths,
size);
if (bytesRead < -1) {
throw new IOException();
}
return bytesRead;
| private native long | readvImpl(int fileDescriptor, int[] addresses, int[] offsets, int[] lengths, int size)
| public long | seek(int fileDescriptor, long offset, int whence)
long pos = seekImpl(fileDescriptor, offset, whence);
if (pos == -1) {
throw new IOException();
}
return pos;
| private native long | seekImpl(int fd, long offset, int whence)
| public long | transfer(int fileHandler, java.io.FileDescriptor socketDescriptor, long offset, long count)
long result = transferImpl(fileHandler, socketDescriptor, offset, count);
if (result < 0) throw new IOException();
return result;
| private native long | transferImpl(int fileHandler, java.io.FileDescriptor socketDescriptor, long offset, long count)
| public void | truncate(int fileDescriptor, long size)
int rc = truncateImpl(fileDescriptor, size);
if (rc < 0) {
throw new IOException();
}
| private native int | truncateImpl(int fileDescriptor, long size)
| public long | ttyRead(byte[] bytes, int offset, int length)
long nChar = ttyReadImpl(bytes, offset, length);
// BEGIN android-changed
if (nChar < -1) {
throw new IOException();
}
// END android-changed
return nChar;
| private native long | ttyReadImpl(byte[] bytes, int offset, int length)
| public void | unlock(int fileDescriptor, long start, long length)
// Validate arguments
validateLockArgs(IFileSystem.SHARED_LOCK_TYPE, start, length);
int result = unlockImpl(fileDescriptor, start, length);
if (result == -1) {
throw new IOException();
}
| private native int | unlockImpl(int fileDescriptor, long start, long length)
| private final void | validateLockArgs(int type, long start, long length)
if ((type != IFileSystem.SHARED_LOCK_TYPE)
&& (type != IFileSystem.EXCLUSIVE_LOCK_TYPE)) {
throw new IllegalArgumentException("Illegal lock type requested."); //$NON-NLS-1$
}
// Start position
if (start < 0) {
throw new IllegalArgumentException(
"Lock start position must be non-negative"); //$NON-NLS-1$
}
// Length of lock stretch
if (length < 0) {
throw new IllegalArgumentException(
"Lock length must be non-negative"); //$NON-NLS-1$
}
| public long | write(int fileDescriptor, byte[] bytes, int offset, int length)
long bytesWritten = writeImpl(fileDescriptor, bytes, offset, length);
if (bytesWritten < 0) {
throw new IOException();
}
return bytesWritten;
| public long | writeDirect(int fileDescriptor, int address, int offset, int length)
long bytesWritten = writeDirectImpl(fileDescriptor, address, offset,
length);
if (bytesWritten < 0) {
throw new IOException();
}
return bytesWritten;
| private native long | writeDirectImpl(int fileDescriptor, int address, int offset, int length)
| private native long | writeImpl(int fileDescriptor, byte[] bytes, int offset, int length)
| public long | writev(int fileDescriptor, int[] addresses, int[] offsets, int[] lengths, int size)
long bytesWritten = writevImpl(fileDescriptor, addresses, offsets,
lengths, size);
if (bytesWritten < 0) {
throw new IOException();
}
return bytesWritten;
| private native long | writevImpl(int fileDescriptor, int[] addresses, int[] offsets, int[] lengths, int size)
|
|