Subfile.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // Created by Иван_Архипов on 01.11.2017.
  3. //
  4. #include "Subfile.h"
  5. #include "BinaryData.h"
  6. #include "DatFile.h"
  7. #include "Common/DatException.h"
  8. #include "Database.h"
  9. #include "Common/CommonFunctions.h"
  10. #include <algorithm>
  11. const long long MAXSIZE = 50ll * 1024ll * 1024ll; // Setting maximal file size 50 MB; Files with size more than 50 mb
  12. // will be recognized as incorrect and passed.
  13. // This should be done because
  14. namespace LOTRO_DAT {
  15. Subfile::Subfile() {}
  16. Subfile::Subfile(DatFile *dat, long long fragments_count, long long unknown1, long long file_id,
  17. long long file_offset,
  18. long long file_size, long long timestamp, long long version, long long block_size) :
  19. dat_(dat), fragments_count_(fragments_count), unknown1_(unknown1), file_id_(file_id),
  20. file_offset_(file_offset),
  21. file_size_(file_size), timestamp_(timestamp), version_(version), block_size_(block_size) {
  22. if (file_size_ > MAXSIZE)
  23. throw DatException("Bad Subfile::Subfile() - File size is too much... Maybe it's incorrect..?",
  24. SUBFILE_EXCEPTION);
  25. }
  26. long long Subfile::fragments_count() const {
  27. return fragments_count_;
  28. }
  29. long long Subfile::unknown1() const {
  30. return unknown1_;
  31. }
  32. long long Subfile::file_id() const {
  33. return file_id_;
  34. }
  35. long long Subfile::file_offset() const {
  36. return file_offset_;
  37. }
  38. long long Subfile::file_size() const {
  39. return file_size_;
  40. }
  41. long long Subfile::timestamp() const {
  42. return timestamp_;
  43. }
  44. long long Subfile::version() const {
  45. return version_;
  46. }
  47. long long Subfile::block_size() const {
  48. return block_size_;
  49. }
  50. FILE_TYPE Subfile::FileType() const {
  51. throw DatException("Bad Subfile::FileType() - function is not implemented for this type.", SUBFILE_EXCEPTION);
  52. }
  53. std::string Subfile::Extension() const {
  54. throw DatException("Bad Subfile::Extension() - function is not implemented for this type.", SUBFILE_EXCEPTION);
  55. }
  56. bool Subfile::PrepareForExport(const BinaryData &file_data, long long &export_size, std::vector<BinaryData> &binary_data,
  57. std::vector<std::u16string> &text_data, std::vector<YAML::Node> &options) {
  58. throw DatException("Bad Subfile::PrepareForExport() - function is not implemented for this type.", EXPORT_EXCEPTION);
  59. }
  60. BinaryData Subfile::MakeForImport(const BinaryData &old_data, const BinaryData &binary_data, const std::u16string &text_data,
  61. const YAML::Node &options) {
  62. throw DatException("Bad Subfile::MakeForImport() - function is not implemented for this type.", IMPORT_EXCEPTION);
  63. }
  64. };