12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- //
- // Created by Иван_Архипов on 24.11.2017.
- //
- #include "JpgSubfile.h"
- #include "../BinaryData.h"
- #include "../DatFile.h"
- #include "../Common/DatException.h"
- namespace LOTRO_DAT {
- JpgSubfile::JpgSubfile() = default;
- JpgSubfile::JpgSubfile(DatFile *dat, long long fragments_count, long long unknown1,
- long long file_id, long long file_offset, long long file_size,
- long long timestamp,
- long long version, long long block_size)
- : Subfile(dat, fragments_count, unknown1, file_id, file_offset, file_size, timestamp, version, block_size) {
- }
- FILE_TYPE JpgSubfile::FileType() const {
- return JPG;
- }
- std::string JpgSubfile::Extension() const {
- return std::string(".jpg");
- }
- bool JpgSubfile::PrepareForExport(const BinaryData &file_data, long long &export_size, std::vector<BinaryData> &binary_data,
- std::vector<std::u16string> &text_data, std::vector<YAML::Node> &options) {
- export_size = 1;
- binary_data.emplace_back(file_data.CutData(24));
- text_data.emplace_back(u"");
- options.emplace_back(YAML::Node());
- options[0]["fid"] = file_id();
- options[0]["ext"] = Extension();
- return true;
- }
- BinaryData JpgSubfile::MakeForImport(const BinaryData &old_data, const BinaryData &binary_data, const std::u16string &text_data,
- const YAML::Node &options) {
- if (!options["ext"] || options["ext"].as<std::string>() != Extension() ||
- !options["fid"] || options["fid"].as<long long>() != file_id()) {
- throw DatException("Bad DdsSubfile::MakeForImport() - invalid options data!", IMPORT_EXCEPTION);
- }
- BinaryData file_size;
- file_size.FromNumber<4>(binary_data.size());
- return old_data.CutData(0, 28) + file_size + binary_data;
- }
- };
|