[Interest] QFile subclass that does HFS compression?

René J. V. Bertin rjvbertin at gmail.com
Mon Dec 17 19:27:37 CET 2018


Thiago Macieira wrote:

> How does that work? Is that just an ioctl, fcntl or a similar system call on
> the open file descriptor? If so, you can do it right now.

Unfortunately, no. Decompression is transparent like you'd expect from a 
filesystem level for of compression, but you have to do the compression 
yourself. And it's a chunked form of compression, but that probably makes it 
easier to integrate it into an existing "write pipe" where you do not already 
have all data ready to be written to storage. 
You also have to maintain a chunk offset table, and a bit of metadata like the 
uncompressed file size. Depending on the size of the compressed data, it's 
stored either as an extended attribute, or else it goes into the file's resource 
fork.

Libarchive has an option to extract the files with HFS compression, if you want 
to have a look at a well-tested implementation. 

> Do you want an API for it?

No, I was thinking of an option to set while opening a file for writing and that 
makes the compression as transparent as possible (seek would probably have to be 
disabled for instance).

> could benefit from this, the proposal would be stronger. NTFS and btrfs have
> compression, for example, and on Linux you can set attributes like secure
> deletion too.

I don't know about secure deletion but the compression in NTFS and btrfs (or 
ZFS) is not a property you request when you open a file AFAIK. It's a filesystem 
property that is set at the level of the directory or dataset. HFS compression 
in QFile would really be Mac-specific, most 3rd-party HFS drivers for other OSes 
do not even support the feature.

R




More information about the Interest mailing list