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

Function extractZip

extlibs/elzip/src/elzip_fs_fallback.cpp:89–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87namespace elz
88{
89 void extractZip(std::string zipname, std::string target)
90 {
91 ziputils::unzipper zipFile;
92 zipFile.open(zipname.c_str());
93 for (std::string filename : zipFile.getFilenames())
94 {
95 std::vector<std::string> splittedPath = split(filename, "/");
96 std::string parentPath = join(splittedPath, "/", 0, 1);
97 std::string cDir(target + ((parentPath == "") ? "" : "/") + parentPath);
98 std::string cFile(target + "/" + filename);
99 std::string fillPath;
100 std::string buffTest = ".";
101 for (std::string pathPart : split(cDir, "/")) {
102
103 fillPath += ((fillPath != "") ? "/" : "") + pathPart;
104 if (!isInList(fillPath, listDirInDir(buffTest))) {
105 createDir(fillPath.c_str());
106 }
107 buffTest = fillPath;
108 }
109 std::cout << "fb] Opening file : " << filename << std::endl;
110 zipFile.openEntry(filename.c_str());
111 std::ofstream wFile;
112 wFile.open(cFile, std::ios_base::binary | std::ios_base::out);
113 std::string dumped = zipFile.dump();
114 wFile.write(dumped.c_str(), dumped.size());
115 wFile.close();
116 }
117 }
118 void extractFile(std::string zipname, std::string filename, std::string target)
119 {
120 ziputils::unzipper zipFile;

Callers

nothing calls this directly

Calls 12

isInListFunction · 0.85
listDirInDirFunction · 0.85
createDirFunction · 0.85
openEntryMethod · 0.80
splitFunction · 0.70
joinFunction · 0.70
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