Files
jak-project/third-party/11zip/src/elzip.cpp
T
Tyler Wilding 9e2b49abaa Automatically watch PCSX2 savestate directory and analyze the EE Memory (#507)
* add elzip library (doesn't require zlib)

* Can analyze directly from a PCSX2 save-state now

* Add scaffolding to auto-watch for new save-states

* .gitattributes fix
2021-05-20 14:18:28 -04:00

49 lines
1.7 KiB
C++
Vendored

#include <fstream>
#include <iostream>
#include <elzip.hpp>
#include <fswrapper.hpp>
#include <unzipper.hpp>
namespace elz
{
void extractZip(std::string zipname, std::string target)
{
ziputils::unzipper zipFile;
zipFile.open(zipname.c_str());
for (std::string filename : zipFile.getFilenames())
{
std::filesystem::path cDir(target + ((std::filesystem::path(filename).parent_path().string() == "") ? "" : "/") + std::filesystem::path(filename).parent_path().string());
std::filesystem::path cFile(target + "/" + filename);
std::filesystem::path fillPath;
for (std::filesystem::path pathPart : cDir)
{
fillPath /= pathPart;
if (!exists(fillPath))
{
create_directory(fillPath);
}
}
std::cout << "Opening file : " << filename << std::endl;
zipFile.openEntry(filename.c_str());
std::ofstream wFile;
wFile.open(cFile.string(), std::ios_base::binary | std::ios_base::out);
std::string dumped = zipFile.dump();
wFile.write(dumped.c_str(), dumped.size());
wFile.close();
}
}
void extractFile(std::string zipname, std::string filename, std::string target)
{
ziputils::unzipper zipFile;
zipFile.open(zipname.c_str());
zipFile.openEntry(filename.c_str());
std::ofstream wFile;
wFile.open(target, std::ios_base::binary | std::ios_base::out);
std::string dumped = zipFile.dump();
wFile.write(dumped.c_str(), dumped.size());
wFile.close();
}
}