Zip.cpp を用いた解凍サンプル
#include <iostream>
#include <cstdio>
using namespace hrk;
using namespace std;
int main(int argc, char *argv[])
{
string zip_file = "test.zip";
if (argc >= 2) {
zip_file = argv[1];
}
if (!zip.
uncompress(zip_file)) {
cerr << "open fail." << endl;
return 1;
}
cerr << "can not read data." << endl;
return 1;
}
fprintf(stderr, "eof: %d\n", zip.eof());
while (!zip.eof()) {
enum { Buffer_size = 1024 };
char buffer[Buffer_size];
int n = zip.
read(buffer, Buffer_size);
fprintf(stderr, "n: %d\n", n);
if (n < 0) {
cerr << "read fail: " << n << endl;
return 1;
}
cout.write(buffer, n);
cout << endl;
}
cout << "uncompressed." << endl;
return 0;
}