1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "orcus/zip_archive.hpp"
#include "orcus/zip_archive_stream.hpp"
#include <cstdlib>
#include <vector>
#include <iostream>
int main(int argc, char** argv)
{
if (argc < 2)
return EXIT_FAILURE;
try
{
orcus::zip_archive_stream_fd stream(argv[1]);
orcus::zip_archive archive(&stream);
archive.load();
size_t n = archive.get_file_entry_count();
if (argc < 3)
{
for (size_t i = 0; i < n; ++i)
{
auto header = archive.get_file_entry_header(i);
std::cout << "--" << std::endl;
std::cout << header << std::endl;
}
return EXIT_SUCCESS;
}
auto header = archive.get_file_entry_header(argv[2]);
std::cout << header << std::endl;
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|