single_file_import_export.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <iostream>
  2. #include "datfile.h"
  3. using namespace LOTRO_DAT;
  4. int main() {
  5. std::string dat_file_path;
  6. std::string target_file_path;
  7. int file_id;
  8. int is_import;
  9. FILE_TYPE file_type = FILE_TYPE::UNKNOWN;
  10. std::cout << "Enter path to .dat file: ";
  11. std::getline(std::cin, dat_file_path);
  12. DatFile file(0);
  13. if (!file.Init(dat_file_path)) {
  14. std::cout << "Failed to open .dat file!" << std::endl;
  15. system("pause");
  16. return 0;
  17. }
  18. std::cout << "Import or export? (enter 1 for import, 0 for export) ";
  19. std::cin >> is_import;
  20. std::cout << "Enter file_id (decimal): ";
  21. std::cin >> file_id;
  22. if (is_import) {
  23. std::string file_type_str;
  24. std::cout << "Enter file type (supported: txt, jpg, dds, wav, ogg, fontbin, unknown): ";
  25. std::cin >> file_type_str;
  26. file_type = FileTypeFromString("." + file_type_str);
  27. }
  28. std::cout << "Enter target file path (without spaces!): ";
  29. std::cin >> target_file_path;
  30. if (is_import == 1) {
  31. std::cout << "IMPORTING!" << std::endl;
  32. file.PatchFile(file_id, file_type, target_file_path);
  33. } else {
  34. std::cout << "EXPORTING!" << std::endl;
  35. file.ExportFileById(file_id, target_file_path);
  36. }
  37. file.Deinit();
  38. return 0;
  39. }