Lightweight 0.20251202.0
Loading...
Searching...
No Matches
Lightweight::Zip::ZipEntry Class Referencefinal

#include <ZipEntry.hpp>

Public Member Functions

 ZipEntry (ZipEntry const &)=delete
 
ZipEntryoperator= (ZipEntry const &)=delete
 
 ZipEntry (ZipEntry &&other) noexcept
 Move constructor. Transfers ownership of the file handle.
 
ZipEntryoperator= (ZipEntry &&other) noexcept
 Move assignment operator. Transfers ownership of the file handle.
 
 ~ZipEntry () noexcept
 Destructor. Closes the entry if open.
 
bool IsOpen () const noexcept
 
std::expected< size_t, ZipErrorRead (std::span< uint8_t > buffer)
 
std::expected< std::vector< uint8_t >, ZipErrorReadAll (size_t expectedSize)
 
void Close () noexcept
 Closes the entry.
 

Detailed Description

RAII wrapper for a ZIP entry file handle (zip_file_t*).

This class provides safe, scoped access to a single entry within a ZIP archive. The entry is automatically closed when the ZipEntry object is destroyed.

ZipEntry objects are non-copyable but movable.

Definition at line 34 of file ZipEntry.hpp.

Member Function Documentation

◆ IsOpen()

bool Lightweight::Zip::ZipEntry::IsOpen ( ) const
noexcept

Checks if the entry is currently open.

Returns
true if the entry is open, false otherwise.

◆ Read()

std::expected< size_t, ZipError > Lightweight::Zip::ZipEntry::Read ( std::span< uint8_t >  buffer)

Reads data from the entry into a buffer.

Parameters
bufferThe buffer to read into.
Returns
The number of bytes read, or a ZipError on failure.

◆ ReadAll()

std::expected< std::vector< uint8_t >, ZipError > Lightweight::Zip::ZipEntry::ReadAll ( size_t  expectedSize)

Reads all data from the entry.

Parameters
expectedSizeThe expected size of the entry in bytes.
Returns
A vector containing all entry data, or a ZipError on failure.

The documentation for this class was generated from the following file: