Zip.cpp を用いたファイルへの展開
#include <iostream>
#include <fstream>
using namespace hrk;
using namespace std;
int main(int argc, char *argv[])
{
string zip_file = "text_1_2.zip";
if (argc >= 2) {
zip_file = argv[1];
}
if (!zip.
uncompress(zip_file)) {
return 1;
}
vector<Zip::header_t> headers = zip.
headers();
for (Zip::Headers::iterator it = headers.begin();
it != headers.end(); ++it) {
zip.
open_read_header(header.
name);
enum { Buffer_size = 4096 };
char buffer[Buffer_size];
ofstream fout(header.name.c_str(), ios_base::binary);
int n = zip.
read(buffer, Buffer_size);
if (n >= 0) {
fout.write(buffer, n);
}
}
}
return 0;
}