MCPcopy Create free account
hub / github.com/Huntereb/Awoo-Installer / extractFile

Function extractFile

source/util/unzip.cpp:114–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112
113namespace inst::zip {
114 bool extractFile(const std::string filename, const std::string destination) {
115 unzFile unz = unzOpen(filename.c_str());
116
117 int i = 0;
118 for (;;) {
119 int code;
120 if (i == 0) {
121 code = unzGoToFirstFile(unz);
122 } else {
123 code = unzGoToNextFile(unz);
124 }
125 i++;
126
127 if (code == UNZ_END_OF_LIST_OF_FILE) {
128 break;
129 } else {
130 unz_file_pos pos;
131 unzGetFilePos(unz, &pos);
132 }
133
134 unz_file_info_s * fileInfo = _getFileInfo(unz);
135
136 std::string fileName = destination;
137 fileName += _getFullFileName(unz, fileInfo);
138
139 if (fileName.back() != '/') {
140 int result = _extractFile(fileName.c_str(), unz, fileInfo);
141 if (result < 0) {
142 free(fileInfo);
143 unzClose(unz);
144 return false;
145 }
146 }
147
148 free(fileInfo);
149 }
150
151 if (i <= 0) {
152 unzClose(unz);
153 return false;
154 }
155
156 unzClose(unz);
157 return true;
158 }
159}

Callers 2

installSigPatchesFunction · 0.85
askToUpdateMethod · 0.85

Calls 3

_getFileInfoFunction · 0.85
_getFullFileNameFunction · 0.85
_extractFileFunction · 0.85

Tested by

no test coverage detected