OggSubfile.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // Created by Иван_Архипов on 24.11.2017.
  3. //
  4. #include "OggSubfile.h"
  5. #include "../BinaryData.h"
  6. #include "../DatFile.h"
  7. #include "../Common/DatException.h"
  8. namespace LOTRO_DAT {
  9. OggSubfile::OggSubfile() {}
  10. OggSubfile::OggSubfile(DatFile *dat, long long fragments_count, long long unknown1,
  11. long long file_id, long long file_offset, long long file_size,
  12. long long timestamp,
  13. long long version, long long block_size)
  14. : Subfile(dat, fragments_count, unknown1, file_id, file_offset, file_size, timestamp, version, block_size) {
  15. }
  16. FILE_TYPE OggSubfile::FileType() const {
  17. return OGG;
  18. }
  19. std::string OggSubfile::Extension() const {
  20. return ".ogg";
  21. }
  22. bool OggSubfile::PrepareForExport(const BinaryData &file_data, long long &export_size, std::vector<BinaryData> &binary_data,
  23. std::vector<std::u16string> &text_data, std::vector<YAML::Node> &options) {
  24. export_size = 1;
  25. binary_data.emplace_back(file_data.CutData(8));
  26. text_data.emplace_back(u"");
  27. options.emplace_back(YAML::Node());
  28. options[0]["file_id"] = file_id();
  29. options[0]["extension"] = Extension();
  30. return true;
  31. }
  32. BinaryData OggSubfile::MakeForImport(const BinaryData &old_data, const BinaryData &binary_data, const std::u16string &text_data,
  33. const YAML::Node &options) {
  34. if (!options["extension"] || options["extension"].as<std::string>() != Extension() ||
  35. !options["file_id"] || options["file_id"].as<long long>() != file_id()) {
  36. throw DatException("Bad DdsSubfile::MakeForImport() - invalid options data!", IMPORT_EXCEPTION);
  37. }
  38. return old_data.CutData(0, 24) + binary_data;
  39. }
  40. };