mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
LibCompress/Gzip: Replace usage of DeprecatedString
This commit is contained in:
parent
7990f1b85a
commit
c30775522e
3 changed files with 7 additions and 7 deletions
|
@ -8,8 +8,8 @@
|
|||
#include <LibCompress/Gzip.h>
|
||||
|
||||
#include <AK/BitStream.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
|
@ -152,17 +152,17 @@ ErrorOr<Bytes> GzipDecompressor::read_some(Bytes bytes)
|
|||
return bytes.slice(0, total_read);
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> GzipDecompressor::describe_header(ReadonlyBytes bytes)
|
||||
ErrorOr<Optional<String>> GzipDecompressor::describe_header(ReadonlyBytes bytes)
|
||||
{
|
||||
if (bytes.size() < sizeof(BlockHeader))
|
||||
return {};
|
||||
return OptionalNone {};
|
||||
|
||||
auto& header = *(reinterpret_cast<BlockHeader const*>(bytes.data()));
|
||||
if (!header.valid_magic_number() || !header.supported_by_implementation())
|
||||
return {};
|
||||
return OptionalNone {};
|
||||
|
||||
LittleEndian<u32> original_size = *reinterpret_cast<u32 const*>(bytes.offset(bytes.size() - sizeof(u32)));
|
||||
return DeprecatedString::formatted("last modified: {}, original size {}", Core::DateTime::from_timestamp(header.modification_time).to_deprecated_string(), (u32)original_size);
|
||||
return TRY(String::formatted("last modified: {}, original size {}", Core::DateTime::from_timestamp(header.modification_time), (u32)original_size));
|
||||
}
|
||||
|
||||
ErrorOr<ByteBuffer> GzipDecompressor::decompress_all(ReadonlyBytes bytes)
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
static ErrorOr<ByteBuffer> decompress_all(ReadonlyBytes);
|
||||
static ErrorOr<void> decompress_file(StringView input_file, NonnullOwnPtr<Stream> output_stream);
|
||||
|
||||
static Optional<DeprecatedString> describe_header(ReadonlyBytes);
|
||||
static ErrorOr<Optional<String>> describe_header(ReadonlyBytes);
|
||||
static bool is_likely_compressed(ReadonlyBytes bytes);
|
||||
|
||||
private:
|
||||
|
|
|
@ -97,7 +97,7 @@ static ErrorOr<Optional<String>> gzip_details(StringView description, StringView
|
|||
if (!Compress::GzipDecompressor::is_likely_compressed(mapped_file->bytes()))
|
||||
return OptionalNone {};
|
||||
|
||||
auto gzip_details = Compress::GzipDecompressor::describe_header(mapped_file->bytes());
|
||||
auto gzip_details = TRY(Compress::GzipDecompressor::describe_header(mapped_file->bytes()));
|
||||
if (!gzip_details.has_value())
|
||||
return OptionalNone {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue