square / okio

A modern I/O library for Android, Java, and Kotlin Multiplatform.
https://square.github.io/okio/
Apache License 2.0
8.76k stars 1.18k forks source link

Is there any API to set last modified time for a file? #1474

Closed andrew-k-21-12 closed 5 months ago

andrew-k-21-12 commented 5 months ago

Greetings!

Are there any APIs to either copy a file with all attributes (metadata) preserved or modify it for some existing file? I'm mostly interested in handling the last modified time.

If not - is it something planned to be added or it's not prioritized now?

P.S. Forgot to mention - the scope of interest is Common (not JVM, JS, Native separately).

JakeWharton commented 5 months ago

See #1466. Since this presumably only applies to the system file system and not arbitrary file systems it would make sense to be an extension.

andrew-k-21-12 commented 5 months ago

Just to make sure I got you correct:

  1. There is no any way to set last modified time for files in okio for common targets now.
  2. There is a plan to support features likes this by using the referenced extensions system which is being designed now.

Is everything right?

JakeWharton commented 5 months ago

Definitely 1. I'm not sure if Jesse plans on supporting this with a built-in extension or whether you'd have to write your own with regard to 2.

swankjesse commented 5 months ago

I like the idea of offering a couple extensions as a first-party optional artifact.