use of com.github.mjdev.libaums.fs.UsbFileInputStream in project samourai-wallet-android by Samourai-Wallet.
the class OpenDimeActivity method readUsbFile.
private String readUsbFile(UsbFile usbFile) {
String ret = null;
try {
UsbFileInputStream inputStream = new UsbFileInputStream(usbFile);
byte[] buf = new byte[(int) usbFile.getLength()];
inputStream.read(buf);
ret = new String(buf, "UTF-8");
} catch (IOException ioe) {
;
}
return ret;
}
use of com.github.mjdev.libaums.fs.UsbFileInputStream 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