WavSubfile.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // Created by Иван_Архипов on 24.11.2017.
  3. //
  4. #include "WavSubfile.h"
  5. #include "../../include/BinaryData.h"
  6. #include "../../include/DatFile.h"
  7. #include "../../include/DatException.h"
  8. #include "../../include/SubfileData.h"
  9. namespace LOTRO_DAT {
  10. WavSubfile::WavSubfile() = default;
  11. WavSubfile::WavSubfile(DatFile *dat, long long dictionary_offset, long long fragments_count, long long unknown1,
  12. long long file_id, long long file_offset, long long file_size, long long timestamp,
  13. long long version, long long block_size)
  14. : Subfile(dat, dictionary_offset, fragments_count, unknown1, file_id, file_offset, file_size, timestamp,
  15. version, block_size) {
  16. }
  17. FILE_TYPE WavSubfile::FileType() const {
  18. return WAV;
  19. }
  20. std::string WavSubfile::Extension() const {
  21. return ".wav";
  22. }
  23. SubfileData WavSubfile::PrepareForExport(const BinaryData &file_data) {
  24. SubfileData result;
  25. result.binary_data = file_data.CutData(8);
  26. result.options["fid"] = file_id();
  27. result.options["ext"] = Extension();
  28. return result;
  29. }
  30. BinaryData WavSubfile::MakeForImport(const BinaryData &old_data, const SubfileData &data) {
  31. if (!data.options["ext"] || data.options["ext"].as<std::string>() != Extension() ||
  32. !data.options["fid"] || data.options["fid"].as<long long>() != file_id()) {
  33. throw DatException("Bad DdsSubfile::MakeForImport() - invalid options data!", IMPORT_EXCEPTION);
  34. }
  35. return old_data.CutData(0, 24) + data.binary_data;
  36. }
  37. };