Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CreatePack(std::list<std::string>& pList, std::string pName, int fSize)
- {
- CZipArchive mZip;
- char szPassword[20 + 1] = "";
- int iPasswordSize = 20;
- mZip.Open(_T(pName.c_str()), CZipArchive::zipCreate);
- EncryptDecryptData(szPassword, iPasswordSize, PassList[2], 20, true);
- mZip.SetPassword(szPassword);
- std::list< std::string >::iterator itr = pList.begin();
- std::string ss2;
- std::string ss3;
- printf("are we going to create this pack?\n");
- while (itr != pList.end())
- {
- std::stringstream ss0;
- ss0 << (*itr);
- std::stringstream ss1;
- ss1 << (*itr);
- ss2 = ss0.str().substr(2);
- ss3 = ss1.str().substr(3 + fSize);
- if (strstr(ss2.c_str(), ".ini") != NULL)
- {
- streampos size;
- char * memblock = NULL;
- printf("adding %s %s\n", ss2.c_str(), ss3.c_str());
- fstream file(ss2.c_str(), ios::in | ios::binary | ios::ate);
- if (file.is_open())
- {
- size = file.tellg();
- memblock = new char[size];
- file.seekg(0, ios::beg);
- file.read(memblock, size);
- file.close();
- }
- EncryptDecryptData(memblock, size, memblock, size, false);
- fstream ofs(ss2.c_str(), ios::out | ios::binary | ios::trunc);
- ofs.write(memblock, size);
- ofs.close();
- if (memblock)
- delete[] memblock;
- }
- //printf("adding %s %s\n", ss2.c_str(), ss3.c_str());
- mZip.AddNewFile(ss2.c_str(), ss3.c_str());
- if (strstr(ss2.c_str(), ".ini") != NULL)
- {
- streampos size;
- char * memblock;
- fstream file(ss2.c_str(), ios::in | ios::binary | ios::ate);
- if (file.is_open())
- {
- size = file.tellg();
- memblock = new char[size];
- file.seekg(0, ios::beg);
- file.read(memblock, size);
- file.close();
- }
- EncryptDecryptData(memblock, size, memblock, size, false);
- fstream ofs(ss2.c_str(), ios::out | ios::binary | ios::trunc);
- ofs.write(memblock, size);
- ofs.close();
- delete[] memblock;
- }
- ++itr;
- }
- mZip.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement