MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / extractZip

Function extractZip

extlibs/elzip/src/elzip.cpp:10–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8namespace elz
9{
10 void extractZip(std::string zipname, std::string target)
11 {
12 ziputils::unzipper zipFile;
13 zipFile.open(zipname.c_str());
14 for (std::string filename : zipFile.getFilenames())
15 {
16 std::filesystem::path cDir(target + ((std::filesystem::path(filename).parent_path().string() == "") ? "" : "/") + std::filesystem::path(filename).parent_path().string());
17 std::filesystem::path cFile(target + "/" + filename);
18 std::filesystem::path fillPath;
19 for (std::filesystem::path pathPart : cDir)
20 {
21 fillPath /= pathPart;
22 if (!exists(fillPath))
23 {
24 create_directory(fillPath);
25 }
26 }
27 std::cout << "Opening file : " << filename << std::endl;
28 zipFile.openEntry(filename.c_str());
29 std::ofstream wFile;
30 wFile.open(cFile.string(), std::ios_base::binary | std::ios_base::out);
31 std::string dumped = zipFile.dump();
32 wFile.write(dumped.c_str(), dumped.size());
33 wFile.close();
34 }
35 }
36
37 void extractFile(std::string zipname, std::string filename, std::string target)
38 {

Callers

nothing calls this directly

Calls 8

stringMethod · 0.80
openEntryMethod · 0.80
openMethod · 0.45
c_strMethod · 0.45
dumpMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected