Use
encodeFiles : List ( FileRecord, Data ) -> Encode.Encoderto tar an arbitrary set of files which may contain either text or binary data. To tar a set of text files, you can use
encodeTextFiles : List (FileRecord, String) -> Encode.EncoderFor more details, see the README. See also the demo app ./examples/Main.elm
Example
fileRecord_ =
Tar.defaultFileRecord
fileRecord1 =
{ fileRecord_ | filename = "a.txt" }
content1 =
"One two three\n"
fileRecord2 =
{ fileRecord_ | filename = "c.binary" }
content2 =
Hex.toBytes "616263646566" |> Maybe.withDefault (encode (Bytes.Encode.unsignedInt8 0))
Tar.encodeFiles
[ ( fileRecord1, StringData content1 )
, ( fileRecord2, BinaryData content2 )
]
|> encode
Note: `Hex` is found in `jxxcarlson/hex`Example
encodeFiles [(defaultFileRecord, "This is a test"), (defaultFileRecord, "Lah di dah do day!")] |> encode == <2594 bytes> : Bytes
defaultFileRecord` does not have any docs. The module's documentation names it in an @docs line, but the package does not expose it.
Use
StringData Stringfor text data,BinaryData Bytesfor binary data