#include "datexportapi.h"
#include "database.h"
#include "subfile.h"

#include <string>


namespace LOTRO_DAT {

class DatFile {
  public:
  	DatFile(int file_handle);
  	~DatFile();
  	bool Init(const std::string& filename);
  	void Deinit();

	size_t GetFilesNumInDatFile();

  	size_t PatchAllFilesFromDatabase(Database& db);
	void PatchFile(SubfileData file_data);
  	void PatchFile(int file_id, FILE_TYPE type, std::string path_to_file);

  	void ExportFilesByTypeToDatabase(FILE_TYPE type, Database& db);
  	void ExportFilesByTypeToDirectory(FILE_TYPE type, std::string path_to_directory);
  	void ExportFileById(int file_id, std::string target_file_path);
  	void ExportFileByIdToDatabase(int file_id, Database& db);

  private:
  	static DatExportApi api_;
  	int file_handle_;
  	bool initialized_;

  	BinaryData export_data_buf_;
};

} // namespace LOTRO_DAT