3
$\begingroup$

I have implemented an Import|Export format for xz that behaves like gzip and other encoding formats:

Import["some.ext.gz"]
Import["some.ext.xz"]

But I think I did it in a really roundabout way, is there a more straightforward way than adding DownValues for all these things:

ImportExport`EncodingsDump`rundecoder["XZ", infile_String, outfile_String, opts___]
ImportExport`EncodingsDump`runencoder["XZ", infile_String, outfile_String, opts___]
FileFormatDump`$FILEFORMATMATRIX["XZ"] (* $ /mma.SE bug *)
ImportExport`EncodingsDump`InstallCoderQ["XZ"]
ImportExport`EncodingsDump`CreateShortName[infile_ /; StringMatchQ[infile, "*.xz"]]
AppendTo[FileFormatDump`$FILEFORMATS, "XZ"]

Together with:

ImportExport`RegisterImport["XZ", ImportXZ,
   "BinaryFormat"->True,
   "Extensions"->{"*.xz"},
   "Encoding"->True,
   "AvailableElements"->{_String},
   "FunctionChannels"->{"FileNames"}]
 (* Similar for Export *)

What's the best way to do this?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.