MCPcopy Create free account
hub / github.com/Kitware/CMake / CompressFile

Method CompressFile

Source/cmGeneratedFileStream.cxx:193–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191
192#ifndef CMAKE_BOOTSTRAP
193int cmGeneratedFileStreamBase::CompressFile(std::string const& oldname,
194 std::string const& newname)
195{
196 gzFile gf = gzopen(newname.c_str(), "w");
197 if (!gf) {
198 return 0;
199 }
200 FILE* ifs = cmsys::SystemTools::Fopen(oldname, "r");
201 if (!ifs) {
202 gzclose(gf);
203 return 0;
204 }
205 size_t res;
206 size_t const BUFFER_SIZE = 1024;
207 char buffer[BUFFER_SIZE];
208 while ((res = fread(buffer, 1, BUFFER_SIZE, ifs)) > 0) {
209 if (!gzwrite(gf, buffer, static_cast<int>(res))) {
210 fclose(ifs);
211 gzclose(gf);
212 return 0;
213 }
214 }
215 fclose(ifs);
216 gzclose(gf);
217 return 1;
218}
219#else
220int cmGeneratedFileStreamBase::CompressFile(std::string const&,
221 std::string const&)

Callers 1

CloseMethod · 0.95

Calls 4

gzopenFunction · 0.85
gzcloseFunction · 0.85
gzwriteFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected