2022-09-04 17:11:14 -04:00
|
|
|
//
|
|
|
|
// EuropaTools
|
|
|
|
//
|
|
|
|
// (C) 2021-2022 modeco80 <lily.modeco80@protonmail.ch>
|
|
|
|
//
|
2022-09-21 03:49:57 -04:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2022-09-04 17:11:14 -04:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef EUROPA_IO_PAKREADER_H
|
|
|
|
#define EUROPA_IO_PAKREADER_H
|
|
|
|
|
2022-09-05 20:59:46 -04:00
|
|
|
#include <europa/io/PakFile.h>
|
|
|
|
#include <europa/structs/Pak.h>
|
|
|
|
|
2022-09-04 17:11:14 -04:00
|
|
|
#include <iosfwd>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace europa::io {
|
|
|
|
|
|
|
|
struct PakReader {
|
2022-09-07 05:07:40 -04:00
|
|
|
using MapType = std::unordered_map<std::string, PakFile>;
|
2022-09-04 17:11:14 -04:00
|
|
|
|
|
|
|
explicit PakReader(std::istream& is);
|
|
|
|
|
|
|
|
void ReadData();
|
|
|
|
|
2022-09-07 05:07:40 -04:00
|
|
|
void ReadFiles();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read in a specific file.
|
|
|
|
*/
|
|
|
|
void ReadFile(const std::string& file);
|
|
|
|
|
2022-09-04 17:11:14 -04:00
|
|
|
bool Invalid() const {
|
|
|
|
return invalid;
|
|
|
|
}
|
|
|
|
|
2022-09-07 05:07:40 -04:00
|
|
|
MapType& GetFiles();
|
|
|
|
const MapType& GetFiles() const;
|
2022-09-04 17:11:14 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::istream& stream;
|
2022-09-05 20:59:46 -04:00
|
|
|
bool invalid { false };
|
2022-09-04 17:11:14 -04:00
|
|
|
|
2022-09-05 20:59:46 -04:00
|
|
|
structs::PakHeader header {};
|
2022-09-04 17:11:14 -04:00
|
|
|
|
2022-09-07 05:07:40 -04:00
|
|
|
MapType files;
|
2022-09-04 17:11:14 -04:00
|
|
|
};
|
|
|
|
|
2022-09-05 20:59:46 -04:00
|
|
|
} // namespace europa::io
|
2022-09-04 17:11:14 -04:00
|
|
|
|
|
|
|
#endif // EUROPA_IO_PAKREADER_H
|