rikyoz / bit7z

A C++ static library offering a clean and simple interface to the 7-zip shared libraries.
https://rikyoz.github.io/bit7z
Mozilla Public License 2.0
602 stars 110 forks source link

[Feature Request]: Can you provide a method for setting the file time #184

Open psvajaz opened 6 months ago

psvajaz commented 6 months ago

Feature description

I hope that during compression, the save creation and access times can be set like FM, and during decompression, if a file in the compressed package has save creation and access times, corresponding event modifications can be made to the output file. I see that your code only determines the modification time of the file. image

Additional context

No response

Code of Conduct

rikyoz commented 6 months ago

Hi!

I hope that during compression, the save creation and access times can be set like FM

Creation and access times should already be stored in the output archive during compression. Unlike FM, though, this is not optional, as bit7z will always store them.

I'll evaluate an API to optionally turn off storing such metadata. The main problem is that those metadata are not "cross-platform", as many filesystems and Unix OSes don't have them.

during decompression, if a file in the compressed package has save creation and access times, corresponding event modifications can be made to the output file. I see that your code only determines the modification time of the file.

Yeah, I'll fix this, possibly in a hotfix release v4.0.6. The main reason for the issue is that the modification time is the only "cross-platform" time metadata, so the fix will use the Windows API to restore the other time metadata.

Also, making this optional might require some thinking in the API, as for the compression case.

How to use the - ssp switch, which was added in the 7-zip version of 20.02

As for the -ssp switch, this must be implemented on the bit7z side; 7-zip DLLs don't accept it (as far as I know). Unfortunately, implementing this feature will not be easy, as bit7z currently uses C++'s std::fstream for file IO, while accessing files without modifying the access time is possible only via WinAPI low-level file IO. I found some possible workaround, but it will probably not be clean, so I'll check whether there are better options.