henrikstengaard / hst-imager

Hst Imager is an imaging tool to read and write disk images to and from physical drives
MIT License
21 stars 1 forks source link

Use file attributes in .uaem files when copying from/to host filesystem #12

Open Optiroc opened 9 months ago

Optiroc commented 9 months ago

How do you feel about adding the option to use the attributes files written by (FS-)UAE when copying to/from the host computer filesystem? I often use UAE with a "work" volume mounted to a plain directory, to which UAE will then write out the Amiga fs attributes to a sidecar .uaem file. I'm sure you're already familiar with these, but for completeness sake they are plain text files on the following format:

hsparwed 2023-12-16 22:41:53.12

Further documentation here.

For reference, a similar feature was added to amitools here.

It would be awesome if I could copy a file tree from my UAE "file volume" to a real Amiga volume with hst.imager with all the attributes intact! I believe that fs copy and fs extract are the commands that would be affected by this feature request.

Also, thanks for a great tool that I'm getting good use of already!

henrikstengaard commented 6 months ago

I initially considered supporting UAEFSDB metadata files when copying from an image file/disk to local directory they would be created and when copying from local directory to an image file/disk use them if they exist to read escaped filename and attributes.

UAEFSDB metadata files seems to work with most Amiga emulators, but was not aware of .uaem metadata files that appears to be introduced with FS-UAE. The content of those files is plain text and very simple, so they should be very easy to support following the format amitools support here https://github.com/cnvogelg/amitools/blob/2a6af0cd778b7e9d11a05618e6996e9a164301b7/amitools/fs/MetaInfoFSUAE.py.

Supporting both would be the best, but I will prioritize .uaem metadata files higher given it's simple format.

henrikstengaard commented 6 months ago

Having looked at FS-UAE documentation https://[fs-uae.net/devel/docs/hard-drives.html](https://fs-uae.net/devel/docs/hard-drives.html) with a simple example I realize that .uaem metadata files are not good enough to support all use cases.

The issue is filenames within Amiga filesystem can contain characters that Windows, Linux and macOS doesn't support. To fix this the metadata files must also save the original filename as it's seen on the Amiga and .uaem metadata files only contain protection attributes, timestamp and comment.

As an example take a look at Calephar WHDLoad game (files version), which contain the filename "CalepharFiles/data/#?+-\". This can't copied to local directory as it's characters aren't support on Windows. Maybe Linux and MacOS can support it to some extent. But there a reason why this WHDLoad game is compressed using lzx and that is to preserve it's filename characters.

A simple approach to support filenames in .uaem metadata files could be to just having an extra line with the filename, something like:

----rwed 2013-02-12 21:20:52.02 hello
Hello#?+-\.data

That should not break the existing format and other tools could still support the first line with protection attributes, timestamp and comment.

henrikstengaard commented 6 months ago

I have done some research and testing of both WinUAE's UAEFSDB files and FS-UAE use of .uaem files. Actually .uaem does already support special AmigaOS filename characters by escaping them with percent + hex value like this "file%2a" to represent filename "file*".