31 lines
842 B
C++
31 lines
842 B
C++
#include <Void/Archive/Archive.hpp>
|
|
|
|
#include <array>
|
|
#include <cstddef>
|
|
|
|
int main()
|
|
{
|
|
const std::array<Void::Archive::CreateEntry, 1> entries{{
|
|
Void::Archive::CreateEntry{
|
|
.path = "hello.txt",
|
|
.type = Void::Archive::EntryType::RegularFile,
|
|
.content = {std::byte{'h'}, std::byte{'i'}},
|
|
},
|
|
}};
|
|
Void::Archive::CreationOptions opts;
|
|
opts.compression = Void::Archive::has_libarchive_backend()
|
|
? Void::Archive::ArchiveCompression::Zstd
|
|
: Void::Archive::ArchiveCompression::None;
|
|
Void::Archive::VectorByteSink sink;
|
|
if (!Void::Archive::create(sink, entries, opts).has_value()) {
|
|
return 1;
|
|
}
|
|
Void::Archive::SpanByteSource src{sink.bytes()};
|
|
auto listed = Void::Archive::list_entries(src);
|
|
if (!listed.has_value() || listed->size() != 1U ||
|
|
(*listed)[0].path != "hello.txt") {
|
|
return 2;
|
|
}
|
|
return 0;
|
|
}
|