Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy file Time stamp issue #357

Open
ssdulawat opened this issue Nov 2, 2022 · 4 comments
Open

Copy file Time stamp issue #357

ssdulawat opened this issue Nov 2, 2022 · 4 comments

Comments

@ssdulawat
Copy link

Problem

When copy file from internal storage to USB storage that time the file copy with current time stamp

Expected behavior

Copy file with same time stamp from source file

Actual behavior

Stacktrace of Excpetion

(if exists)

Code where problem occurs

  InputStream inputStream = new BufferedInputStream(App.getContext().getContentResolver().openInputStream(uri));
  OutputStream outputStream = UsbFileStreamFactory.createBufferedOutputStream(file, currentFs);
  try {
    byte[] bytes = new byte[currentFs.getChunkSize()];
    int count;
    long bytesWritten = 0;

    while ((count = inputStream.read(bytes)) != -1) {

      if (stopWrite) {
        Timber.d("Copying interrupted!");
        file.delete();
        break;
      }

      outputStream.write(bytes, 0, count);

      bytesWritten += count;
      int progress = (int) (((double) bytesWritten / (double) size) * 100.0);
      if (progressListener != null) progressListener.onProgress(progress, 100);
    }

    outputStream.close();
    inputStream.close();
@ssdulawat
Copy link
Author

Please let me know for the solution.
I am using libaums 0.7.4

@magnusja
Copy link
Owner

You are copying a stream of bytes, you have to set the timestamps yourself. This is currently not exposed over the public API but probably not too hard to add.

@ssdulawat
Copy link
Author

How to set timestamp on outputStream file that library method there is no way to add it. please suggest me any example.

@magnusja
Copy link
Owner

magnusja commented Apr 3, 2023

Currently, there is no way. You would need to add this to the UsbFile API. I am happy to take a Pull Request for that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants