mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Libraries: Change enums to enum classes in LibArchive
This commit is contained in:
parent
3eb6016dda
commit
be360db223
Notes:
sideshowbarker
2024-07-17 17:10:15 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/be360db223 Pull-request: https://github.com/SerenityOS/serenity/pull/13099
2 changed files with 21 additions and 14 deletions
|
@ -9,6 +9,11 @@
|
|||
|
||||
namespace Archive {
|
||||
|
||||
OutputStream& operator<<(OutputStream& stream, ZipCompressionMethod method)
|
||||
{
|
||||
return stream << to_underlying(method);
|
||||
}
|
||||
|
||||
bool Zip::find_end_of_central_directory_offset(ReadonlyBytes buffer, size_t& offset)
|
||||
{
|
||||
for (size_t backwards_offset = 0; backwards_offset <= UINT16_MAX; backwards_offset++) // the file may have a trailing comment of an arbitrary 16 bit length
|
||||
|
@ -90,7 +95,7 @@ bool Zip::for_each_member(Function<IterationDecision(const ZipMember&)> callback
|
|||
null_terminated_name[central_directory_record.name_length] = 0;
|
||||
member.name = String { null_terminated_name };
|
||||
member.compressed_data = { local_file_header.compressed_data, central_directory_record.compressed_size };
|
||||
member.compression_method = static_cast<ZipCompressionMethod>(central_directory_record.compression_method);
|
||||
member.compression_method = central_directory_record.compression_method;
|
||||
member.uncompressed_size = central_directory_record.uncompressed_size;
|
||||
member.crc32 = central_directory_record.crc32;
|
||||
member.is_directory = central_directory_record.external_attributes & zip_directory_external_attribute || member.name.ends_with('/'); // FIXME: better directory detection
|
||||
|
|
|
@ -70,13 +70,27 @@ struct [[gnu::packed]] EndOfCentralDirectory {
|
|||
}
|
||||
};
|
||||
|
||||
enum class ZipCompressionMethod : u16 {
|
||||
Store = 0,
|
||||
Shrink = 1,
|
||||
Reduce1 = 2,
|
||||
Reduce2 = 3,
|
||||
Reduce3 = 4,
|
||||
Reduce4 = 5,
|
||||
Implode = 6,
|
||||
Reserved = 7,
|
||||
Deflate = 8
|
||||
};
|
||||
|
||||
OutputStream& operator<<(OutputStream& stream, ZipCompressionMethod method);
|
||||
|
||||
struct [[gnu::packed]] CentralDirectoryRecord {
|
||||
static constexpr Array<u8, signature_length> signature = { 0x50, 0x4b, 0x01, 0x02 }; // 'PK\x01\x02'
|
||||
|
||||
u16 made_by_version;
|
||||
u16 minimum_version;
|
||||
u16 general_purpose_flags;
|
||||
u16 compression_method;
|
||||
ZipCompressionMethod compression_method;
|
||||
u16 modification_time;
|
||||
u16 modification_date;
|
||||
u32 crc32;
|
||||
|
@ -192,18 +206,6 @@ struct [[gnu::packed]] LocalFileHeader {
|
|||
}
|
||||
};
|
||||
|
||||
enum ZipCompressionMethod : u16 {
|
||||
Store = 0,
|
||||
Shrink = 1,
|
||||
Reduce1 = 2,
|
||||
Reduce2 = 3,
|
||||
Reduce3 = 4,
|
||||
Reduce4 = 5,
|
||||
Implode = 6,
|
||||
Reserved = 7,
|
||||
Deflate = 8
|
||||
};
|
||||
|
||||
struct ZipMember {
|
||||
String name;
|
||||
ReadonlyBytes compressed_data; // TODO: maybe the decompression/compression should be handled by LibArchive instead of the user?
|
||||
|
|
Loading…
Reference in a new issue