趣味で作ってるロボット用ソフトウェア
 All Classes Files Functions Enumerations Enumerator Friends Pages
zip_uncompress.cpp

Zip.cpp を用いた解凍サンプル

#include <iostream>
#include <cstdio>
#include "Zip.h"
using namespace hrk;
using namespace std;
int main(int argc, char *argv[])
{
string zip_file = "test.zip";
if (argc >= 2) {
zip_file = argv[1];
}
Zip zip;
if (!zip.uncompress(zip_file)) {
cerr << "open fail." << endl;
return 1;
}
if (zip.eof()) {
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;
}
zip.close();
cout << "uncompressed." << endl;
return 0;
}