123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #include "Subfile.h"
- #include "BinaryData.h"
- #include "DatFile.h"
- #include "Common/DatException.h"
- #include "SubfileData.h"
- #include <algorithm>
- const long long MAXSIZE = 50ll * 1024ll * 1024ll;
-
-
-
- namespace LOTRO_DAT {
- Subfile::Subfile() = default;
- Subfile::Subfile(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) :
- dat_(dat), dictionary_offset_(dictionary_offset), fragments_count_(fragments_count), unknown1_(unknown1), file_id_(file_id),
- file_offset_(file_offset),
- file_size_(file_size), timestamp_(timestamp), version_(version), block_size_(block_size) {
- if (file_size_ > MAXSIZE)
- throw DatException("Bad Subfile::Subfile() - File size is too much... Maybe it's incorrect..?",
- SUBFILE_EXCEPTION);
- }
-
- long long Subfile::dictionary_offset() const {
- return dictionary_offset_;
- }
- long long Subfile::fragments_count() const {
- return fragments_count_;
- }
- long long Subfile::unknown1() const {
- return unknown1_;
- }
- long long Subfile::file_id() const {
- return file_id_;
- }
- long long Subfile::file_offset() const {
- return file_offset_;
- }
- long long Subfile::file_size() const {
- return file_size_;
- }
- long long Subfile::timestamp() const {
- return timestamp_;
- }
- long long Subfile::version() const {
- return version_;
- }
- long long Subfile::block_size() const {
- return block_size_;
- }
-
-
-
- FILE_TYPE Subfile::FileType() const {
- throw DatException("Bad Subfile::FileType() - function is not implemented for this type.", SUBFILE_EXCEPTION);
- }
-
-
-
- std::string Subfile::Extension() const {
- throw DatException("Bad Subfile::Extension() - function is not implemented for this type.", SUBFILE_EXCEPTION);
- }
-
-
-
-
-
-
-
-
- SubfileData Subfile::PrepareForExport(const BinaryData &file_data) {
- throw DatException("Bad Subfile::PrepareForExport() - function is not implemented for this type.", EXPORT_EXCEPTION);
- }
-
-
-
-
-
-
-
- BinaryData Subfile::MakeForImport(const BinaryData &old_data, const SubfileData &data) {
- throw DatException("Bad Subfile::MakeForImport() - function is not implemented for this type.", IMPORT_EXCEPTION);
- }
- BinaryData Subfile::MakeHeaderData() const {
- BinaryData header;
- BinaryData data(4);
- data.FromNumber<4>(fragments_count_);
- header = header + data;
- data.FromNumber<4>(unknown1_);
- header = header + data;
- data.FromNumber<4>(file_id_);
- header = header + data;
- data.FromNumber<4>(file_offset_);
- header = header + data;
- data.FromNumber<4>(file_size_);
- header = header + data;
- data.FromNumber<4>(timestamp_);
- header = header + data;
- data.FromNumber<4>(version_);
- header = header + data;
- data.FromNumber<4>(block_size_);
- header = header + data;
- return header;
- }
- };
|