// // Created by Иван_Архипов on 24.11.2017. // #include "JpgSubfile.h" #include "../BinaryData.h" #include "../DatFile.h" #include "../Common/DatException.h" #include "../SubfileData.h" namespace LOTRO_DAT { JpgSubfile::JpgSubfile() = default; JpgSubfile::JpgSubfile(DatFile *dat, long long dictionary_offset, 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, dictionary_offset, 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"); } std::vector JpgSubfile::PrepareForExport(const BinaryData &file_data) { std::vector output(1); output[0].binary_data = file_data.CutData(24); output[0].text_data = u""; output[0].options["fid"] = file_id(); output[0].options["ext"] = Extension(); return output; } BinaryData JpgSubfile::MakeForImport(const BinaryData &old_data, const SubfileData &data) { if (!data.options["ext"] || data.options["ext"].as() != Extension() || !data.options["fid"] || data.options["fid"].as() != file_id()) { throw DatException("Bad DdsSubfile::MakeForImport() - invalid options data!", IMPORT_EXCEPTION); } BinaryData file_size; file_size.FromNumber<4>(data.binary_data.size()); return old_data.CutData(0, 28) + file_size + data.binary_data; } };