| 191 | |
| 192 | #ifndef CMAKE_BOOTSTRAP |
| 193 | int 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 |
| 220 | int cmGeneratedFileStreamBase::CompressFile(std::string const&, |
| 221 | std::string const&) |