6#include <sourcepp/fs/FS.h>
13 if (!std::filesystem::exists(path)) {
19 auto* example =
new EXAMPLE{path};
20 auto packFile = std::unique_ptr<PackFile>(example);
25 std::vector<std::string> samplePaths{
26 {
"a/b/c/skibidi_toilet.png"},
27 {
"d/c/boykisser.mdl"},
30 for (
const auto& entryPath_ : samplePaths) {
32 auto entryPath = example->cleanEntryPath(entryPath_);
45 example->entries.emplace(entryPath, entry);
49 callback(entryPath, entry);
81 std::string outputPath = outputDir +
'/' + this->
getFilename();
95 callback(path, entry);
void addEntryInternal(Entry &entry, const std::string &path, std::vector< std::byte > &buffer, EntryOptions options) override
std::optional< std::vector< std::byte > > readEntry(const std::string &path_) const override
Try to read the entry's data to a bytebuffer.
bool bake(const std::string &outputDir_, BakeOptions options, const EntryCallback &callback) override
If output folder is an empty string, it will overwrite the original.
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
This class represents the metadata that a file has inside a PackFile.
uint32_t crc32
CRC32 checksum - 0 if unused.
uint64_t length
Length in bytes (in formats with compression, this is the uncompressed length)
EntryCallbackBase< void > EntryCallback
void mergeUnbakedEntries()
std::optional< Entry > findEntry(const std::string &path_, bool includeUnbaked=true) const
Try to find an entry given the file path.
std::string getFilename() const
/home/user/pak01_dir.vpk -> pak01_dir.vpk
std::string getBakeOutputDir(const std::string &outputDir) const
void runForAllEntries(const EntryCallback &operation, bool includeUnbaked=true) const
Run a callback for each entry in the pack file.
void setFullFilePath(const std::string &outputDir)
std::string cleanEntryPath(const std::string &path) const
static Entry createNewEntry()
static std::optional< std::vector< std::byte > > readUnbakedEntry(const Entry &entry)