mirror of
https://github.com/open-goal/jak-project
synced 2026-08-14 12:34:36 -04:00
9e2b49abaa
* 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
49 lines
1.7 KiB
C++
Vendored
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();
|
|
}
|
|
}
|