Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. void CreatePack(std::list<std::string>& pList, std::string pName, int fSize)
  2. {
  3. CZipArchive mZip;
  4. char szPassword[20 + 1] = "";
  5. int iPasswordSize = 20;
  6. mZip.Open(_T(pName.c_str()), CZipArchive::zipCreate);
  7. EncryptDecryptData(szPassword, iPasswordSize, PassList[2], 20, true);
  8. mZip.SetPassword(szPassword);
  9.  
  10. std::list< std::string >::iterator itr = pList.begin();
  11. std::string ss2;
  12. std::string ss3;
  13. printf("are we going to create this pack?\n");
  14. while (itr != pList.end())
  15. {
  16. std::stringstream ss0;
  17. ss0 << (*itr);
  18. std::stringstream ss1;
  19. ss1 << (*itr);
  20. ss2 = ss0.str().substr(2);
  21. ss3 = ss1.str().substr(3 + fSize);
  22. if (strstr(ss2.c_str(), ".ini") != NULL)
  23. {
  24. streampos size;
  25. char * memblock = NULL;
  26. printf("adding %s %s\n", ss2.c_str(), ss3.c_str());
  27. fstream file(ss2.c_str(), ios::in | ios::binary | ios::ate);
  28. if (file.is_open())
  29. {
  30. size = file.tellg();
  31. memblock = new char[size];
  32. file.seekg(0, ios::beg);
  33. file.read(memblock, size);
  34. file.close();
  35. }
  36. EncryptDecryptData(memblock, size, memblock, size, false);
  37. fstream ofs(ss2.c_str(), ios::out | ios::binary | ios::trunc);
  38. ofs.write(memblock, size);
  39. ofs.close();
  40. if (memblock)
  41. delete[] memblock;
  42. }
  43. //printf("adding %s %s\n", ss2.c_str(), ss3.c_str());
  44.  
  45. mZip.AddNewFile(ss2.c_str(), ss3.c_str());
  46. if (strstr(ss2.c_str(), ".ini") != NULL)
  47. {
  48. streampos size;
  49. char * memblock;
  50. fstream file(ss2.c_str(), ios::in | ios::binary | ios::ate);
  51. if (file.is_open())
  52. {
  53. size = file.tellg();
  54. memblock = new char[size];
  55. file.seekg(0, ios::beg);
  56. file.read(memblock, size);
  57. file.close();
  58. }
  59. EncryptDecryptData(memblock, size, memblock, size, false);
  60.  
  61. fstream ofs(ss2.c_str(), ios::out | ios::binary | ios::trunc);
  62. ofs.write(memblock, size);
  63. ofs.close();
  64. delete[] memblock;
  65. }
  66. ++itr;
  67. }
  68. mZip.Close();
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement