Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public synchronized InputStream getInputStream(UsbMassStorageDevice device, FileItem fileItem)
- throws USBException, IOException {
- Timber.tag(TAG).d("getInputStream: open stream %s ...", fileItem.getPath());
- FileSystem fs = getFs(device);
- UsbFile rootDir = fs.getRootDirectory();
- // getRelativePath return /folder/file.txt for path /Usb_prefix/folder/file.txt
- UsbFile srcFile = rootDir.search(getRelativePath(fs, fileItem.getPath()));
- if (srcFile == null)
- throw new USBException(USBErrorCode.FILE_NOT_FOUND);
- return UsbFileStreamFactory.createBufferedInputStream(srcFile, fs);
- }
- @Override
- public synchronized OutputStream getOutputStream(UsbMassStorageDevice device, FileItem fileItem)
- throws IOException, USBException {
- Timber.tag(TAG).d("getOutputStream: open stream %s ...", fileItem.getPath());
- FileSystem fs = getFs(device);
- UsbFile rootDir = fs.getRootDirectory();
- UsbFile srcFile = rootDir.search(getRelativePath(fs, fileItem.getPath()));
- if (srcFile != null)
- throw new USBException(USBErrorCode.FILE_EXISTS);
- //create parent folder for srcFile
- UsbFile srcFileParentFolder = mkDirs(device, constructParentFileItem(fileItem));
- srcFile = srcFileParentFolder.createFile(fileItem.getName());
- return UsbFileStreamFactory.createBufferedOutputStream(srcFile, fs);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement