Fields Summary |
---|
private final FileDescriptor | mFileDescriptor |
private boolean | mClosed |
private final ParcelFileDescriptor | mParcelDescriptor |
public static final int | MODE_WORLD_READABLEFor use with {@link #open}: if {@link #MODE_CREATE} has been supplied
and this file doesn't already exist, then create the file with
permissions such that any application can read it. |
public static final int | MODE_WORLD_WRITEABLEFor use with {@link #open}: if {@link #MODE_CREATE} has been supplied
and this file doesn't already exist, then create the file with
permissions such that any application can write it. |
public static final int | MODE_READ_ONLYFor use with {@link #open}: open the file with read-only access. |
public static final int | MODE_WRITE_ONLYFor use with {@link #open}: open the file with write-only access. |
public static final int | MODE_READ_WRITEFor use with {@link #open}: open the file with read and write access. |
public static final int | MODE_CREATEFor use with {@link #open}: create the file if it doesn't already exist. |
public static final int | MODE_TRUNCATEFor use with {@link #open}: erase contents of file when opening. |
public static final int | MODE_APPENDFor use with {@link #open}: append to end of file while writing. |
public static final Parcelable.Creator | CREATOR |
Methods Summary |
---|
public void | close()Close the ParcelFileDescriptor. This implementation closes the underlying
OS resources allocated to represent this stream.
mClosed = true;
if (mParcelDescriptor != null) {
// If this is a proxy to another file descriptor, just call through to its
// close method.
mParcelDescriptor.close();
} else {
Parcel.closeFileDescriptor(mFileDescriptor);
}
|
public int | describeContents()
return Parcelable.CONTENTS_FILE_DESCRIPTOR;
|
protected void | finalize()
try {
if (!mClosed) {
close();
}
} finally {
super.finalize();
}
|
public static android.os.ParcelFileDescriptor | fromSocket(java.net.Socket socket)Create a new ParcelFileDescriptor from the specified Socket.
FileDescriptor fd = getFileDescriptorFromSocket(socket);
return new ParcelFileDescriptor(fd);
|
public java.io.FileDescriptor | getFileDescriptor()Retrieve the actual FileDescriptor associated with this object.
return mFileDescriptor;
|
private static native java.io.FileDescriptor | getFileDescriptorFromSocket(java.net.Socket socket)
|
public native long | getStatSize()Return the total size of the file representing this fd, as determined
by stat(). Returns -1 if the fd is not a file.
|
public static android.os.ParcelFileDescriptor | open(java.io.File file, int mode)Create a new ParcelFileDescriptor accessing a given file.
String path = file.getPath();
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
if ((mode&MODE_WRITE_ONLY) != 0) {
security.checkWrite(path);
}
}
if ((mode&MODE_READ_WRITE) == 0) {
throw new IllegalArgumentException(
"Must specify MODE_READ_ONLY, MODE_WRITE_ONLY, or MODE_READ_WRITE");
}
FileDescriptor fd = Parcel.openFileDescriptor(path, mode);
return new ParcelFileDescriptor(fd);
|
public native long | seekTo(long pos)This is needed for implementing AssetFileDescriptor.AutoCloseOutputStream,
and I really don't think we want it to be public.
|
public java.lang.String | toString()
return "{ParcelFileDescriptor: " + mFileDescriptor + "}";
|
public void | writeToParcel(Parcel out, int flags)
out.writeFileDescriptor(mFileDescriptor);
if ((flags&PARCELABLE_WRITE_RETURN_VALUE) != 0 && !mClosed) {
try {
close();
} catch (IOException e) {
// Empty
}
}
|