TarStream: Make read_contents and friends const

This commit is contained in:
apio 2022-12-23 13:08:31 +01:00
parent ad0f6546d7
commit e5ae2b0435
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 4 additions and 4 deletions

View File

@ -33,9 +33,9 @@ class TarStream
void rewind(); void rewind();
usize read_contents(const Entry& entry, void* buf, usize offset, usize length); usize read_contents(const Entry& entry, void* buf, usize offset, usize length) const;
Result<OwnedStringView> read_contents_as_string(const Entry& entry, usize offset, usize max); Result<OwnedStringView> read_contents_as_string(const Entry& entry, usize offset, usize max) const;
private: private:
struct [[gnu::packed]] TarHeader struct [[gnu::packed]] TarHeader

View File

@ -87,7 +87,7 @@ Result<TarStream::Entry> TarStream::read_next_entry()
return parse_header(&header); return parse_header(&header);
} }
usize TarStream::read_contents(const Entry& entry, void* buf, usize offset, usize length) usize TarStream::read_contents(const Entry& entry, void* buf, usize offset, usize length) const
{ {
if (offset >= entry.size) return 0; if (offset >= entry.size) return 0;
if ((length + offset) > entry.size) length = entry.size - offset; if ((length + offset) > entry.size) length = entry.size - offset;
@ -97,7 +97,7 @@ usize TarStream::read_contents(const Entry& entry, void* buf, usize offset, usiz
return length; return length;
} }
Result<OwnedStringView> TarStream::read_contents_as_string(const Entry& entry, usize offset, usize max) Result<OwnedStringView> TarStream::read_contents_as_string(const Entry& entry, usize offset, usize max) const
{ {
char* buf = TRY(make_array<char>(max + 1)); char* buf = TRY(make_array<char>(max + 1));