Search in sources :

Example 1 with UsbFileInputStream

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;
}
Also used : SpannableString(android.text.SpannableString) IOException(java.io.IOException) UsbFileInputStream(com.github.mjdev.libaums.fs.UsbFileInputStream)

Example 2 with UsbFileInputStream

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());
    }
}
Also used : UsbFile(com.github.mjdev.libaums.fs.UsbFile) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) UsbFileInputStream(com.github.mjdev.libaums.fs.UsbFileInputStream) UsbFileOutputStream(com.github.mjdev.libaums.fs.UsbFileOutputStream)

Aggregations

UsbFileInputStream (com.github.mjdev.libaums.fs.UsbFileInputStream)2 IOException (java.io.IOException)2 SpannableString (android.text.SpannableString)1 UsbFile (com.github.mjdev.libaums.fs.UsbFile)1 UsbFileOutputStream (com.github.mjdev.libaums.fs.UsbFileOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1