use of com.github.mjdev.libaums.fs.UsbFileOutputStream in project AnExplorer by 1hakr.
the class UsbStorageProvider method openDocument.
@Override
public ParcelFileDescriptor openDocument(String documentId, String mode, CancellationSignal signal) throws FileNotFoundException {
try {
UsbFile file = getFileForDocId(documentId);
/* final int accessMode = ParcelFileDescriptorUtil.parseMode(mode);
if ((accessMode | ParcelFileDescriptor.MODE_READ_ONLY) == ParcelFileDescriptor.MODE_READ_ONLY) {
return ParcelFileDescriptorUtil.pipeFrom(new UsbFileInputStream(file));
} else if ((accessMode | ParcelFileDescriptor.MODE_WRITE_ONLY) == ParcelFileDescriptor.MODE_WRITE_ONLY) {
return ParcelFileDescriptorUtil.pipeTo(new UsbFileOutputStream(file));
}*/
final boolean isWrite = (mode.indexOf('w') != -1);
if (isWrite) {
return ParcelFileDescriptorUtil.pipeTo(new UsbFileOutputStream(file));
} else {
return ParcelFileDescriptorUtil.pipeFrom(new UsbFileInputStream(file));
}
} catch (IOException e) {
throw new FileNotFoundException(e.getMessage());
}
}
Aggregations