SARC¶
API¶
#include <oead/sarc.h>
-
class
Sarc¶ A simple SARC archive reader.
Public Functions
-
Sarc(tcb::span<const u8> data)¶
-
u16
GetNumFiles() const¶ Get the number of files that are stored in the archive.
-
u32
GetDataOffset() const¶ Get the offset to the beginning of file data.
-
util::Endianness
GetEndianness() const¶ Get the archive endianness.
-
auto
GetFiles() const¶ Returns an iterator over the contained files.
-
size_t
GuessMinAlignment() const¶ Guess the minimum data alignment for files that are stored in the archive.
-
struct
File¶ A file that is stored in a SARC archive.
Public Functions
-
-
class
SarcWriter¶ Public Types
-
enum
Mode¶ Values:
-
Legacy¶ Used for games with an old-style resource system that requires aligning nested SARCs and manual alignment of file data in archives.
-
New¶ Used for games with a new-style resource system that automatically takes care of data alignment and does not require manual alignment nor nested SARC alignment.
-
-
using
FileMap= absl::flat_hash_map<std::string, std::vector<u8>>¶ - Warning
The map type is an implementation detail.
Public Functions
-
SarcWriter(util::Endianness endian = util::Endianness::Little, Mode mode = Mode::New)¶
-
std::pair<u32, std::vector<u8>>
Write()¶ Write a SARC archive using the specified endianness. Default alignment requirements may be automatically added.
- Return
the required data alignment and the data.
-
void
SetEndianness(util::Endianness endian)¶ Set the endianness.
-
void
SetMinAlignment(size_t alignment)¶ Set the minimum data alignment.
- Parameters
alignment: Data alignment (must be a power of 2)
-
void
AddAlignmentRequirement(std::string extension_without_dot, size_t alignment)¶ Add or modify a data alignment requirement for a file type. Set the alignment to 1 to revert.
- Parameters
extension_without_dot: File extension without the dot (e.g. “bgparamlist”)alignment: Data alignment (must be a power of 2)
Public Static Functions
-
static SarcWriter
FromSarc(const Sarc &archive)¶ Make a SarcWriter from a SARC archive. The endianness, data alignment and file content will be copied from the SARC.
- Parameters
archive: Source archive
-
enum