libluna/TarStream: Remove unused functionality
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b9e8030aac
commit
d86da05bea
@ -1,5 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <luna/OwnedStringView.h>
|
|
||||||
#include <luna/Result.h>
|
#include <luna/Result.h>
|
||||||
#include <luna/Types.h>
|
#include <luna/Types.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -26,7 +25,6 @@ class TarStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
usize m_pos;
|
|
||||||
u8* m_data;
|
u8* m_data;
|
||||||
|
|
||||||
friend class TarStream;
|
friend class TarStream;
|
||||||
@ -41,10 +39,6 @@ class TarStream
|
|||||||
|
|
||||||
void rewind();
|
void rewind();
|
||||||
|
|
||||||
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) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct [[gnu::packed]] TarHeader
|
struct [[gnu::packed]] TarHeader
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,6 @@ Result<TarStream::Entry> TarStream::parse_header(const TarStream::TarHeader* hdr
|
|||||||
|
|
||||||
entry.mode = (mode_t)parse_unsigned_integer(hdr->mode, nullptr, 8);
|
entry.mode = (mode_t)parse_unsigned_integer(hdr->mode, nullptr, 8);
|
||||||
|
|
||||||
entry.m_pos = m_offset;
|
|
||||||
entry.m_data = (u8*)m_base + m_offset;
|
entry.m_data = (u8*)m_base + m_offset;
|
||||||
|
|
||||||
switch (hdr->typeflag)
|
switch (hdr->typeflag)
|
||||||
@ -94,24 +93,3 @@ Result<bool> TarStream::read_next_entry(Entry& out)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
usize TarStream::read_contents(const Entry& entry, void* buf, usize offset, usize length) const
|
|
||||||
{
|
|
||||||
if (offset >= entry.size) return 0;
|
|
||||||
if ((length + offset) > entry.size) length = entry.size - offset;
|
|
||||||
|
|
||||||
memcpy(buf, offset_ptr(m_base, entry.m_pos + offset), length);
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<OwnedStringView> TarStream::read_contents_as_string(const Entry& entry, usize offset, usize max) const
|
|
||||||
{
|
|
||||||
char* const buf = TRY(make_array<char>(max + 1));
|
|
||||||
|
|
||||||
usize nread = read_contents(entry, buf, offset, max);
|
|
||||||
|
|
||||||
buf[nread] = 0;
|
|
||||||
|
|
||||||
return OwnedStringView { buf };
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user