TarStream: Add a direct pointer to entry data in the Entry struct
This commit is contained in:
parent
e5a41d2d52
commit
6fd28379a9
@ -20,8 +20,14 @@ class TarStream
|
||||
mode_t mode;
|
||||
EntryType type;
|
||||
|
||||
const u8* data() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
private:
|
||||
usize pos;
|
||||
usize m_pos;
|
||||
u8* m_data;
|
||||
|
||||
friend class TarStream;
|
||||
};
|
||||
|
@ -45,7 +45,8 @@ Result<TarStream::Entry> TarStream::parse_header(const TarStream::TarHeader* hdr
|
||||
|
||||
entry.mode = (mode_t)parse_unsigned_integer(hdr->mode, nullptr, 8);
|
||||
|
||||
entry.pos = m_offset;
|
||||
entry.m_pos = m_offset;
|
||||
entry.m_data = (u8*)(m_base + m_offset);
|
||||
|
||||
switch (hdr->typeflag)
|
||||
{
|
||||
@ -99,7 +100,7 @@ usize TarStream::read_contents(const Entry& entry, void* buf, usize offset, usiz
|
||||
if (offset >= entry.size) return 0;
|
||||
if ((length + offset) > entry.size) length = entry.size - offset;
|
||||
|
||||
memcpy(buf, offset_ptr(m_base, entry.pos + offset), length);
|
||||
memcpy(buf, offset_ptr(m_base, entry.m_pos + offset), length);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user