mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-13 18:02:01 -04:00
ddl_ar tool to work with ddls
This commit is contained in:
parent
3eb73c4ad1
commit
054cc48e15
5 changed files with 183 additions and 0 deletions
49
tools/ddl_ar_class.h
Normal file
49
tools/ddl_ar_class.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
class DDLArchive {
|
||||
public:
|
||||
|
||||
struct FileRec {
|
||||
uint32_t offset;
|
||||
std::filesystem::path source;
|
||||
|
||||
};
|
||||
|
||||
|
||||
using Directory = std::map<std::string, FileRec, std::less<> >;
|
||||
bool open(std::filesystem::path ar_file);
|
||||
const Directory &get_directory() const {return _directory;}
|
||||
const std::filesystem::path& get_ar_file() const {return _ar_file;}
|
||||
|
||||
struct Extracted {
|
||||
std::string_view name;
|
||||
bool found;
|
||||
std::vector<char> data;
|
||||
};
|
||||
|
||||
|
||||
template<typename Iter, std::invocable<Extracted> CB>
|
||||
void extract(Iter from, Iter to, CB &&cb) {
|
||||
std::ifstream f = begin_read();
|
||||
while (from != to) {
|
||||
std::string_view n = *from;
|
||||
cb(extract_file(f, n));
|
||||
++from;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
std::filesystem::path _ar_file;
|
||||
Directory _directory;
|
||||
|
||||
std::ifstream begin_read();
|
||||
Extracted extract_file(std::ifstream &s, std::string_view fname);
|
||||
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue