Zipios++
zipoutputstreamtest.cpp
Go to the documentation of this file.
1
2#include <stdlib.h>
3
4#include "zipios++/zipios-config.h"
5#include "zipios++/meta-iostreams.h"
6
8
9#include "zipoutputstreamtest.h"
10
11using namespace zipios ;
12
13using std::cout ;
14using std::cerr ;
15using std::endl ;
16using std::istream ;
17using std::ios ;
18using std::ofstream ;
19using std::string ;
20
21const string zipios::ZipOutputStreamTest::TEST_ZIPFILE_NAME = "testout.zip";
22const TestFiles zipios::ZipOutputStreamTest::TEST_FILES;
23
24
25void zipios::ZipOutputStreamTest::testNativeUnzip() {
26 if (! hasUnzip()) {
27 cout << "'unzip' not present, skipping ZipFileTest::testNativeUnzip"
28 << endl;
29 return;
30 }
31
32 ZipOutputStream zos(TEST_ZIPFILE_NAME);
33
34 std::vector<string>::const_iterator it;
35 for(it=TEST_FILES.begin(); it!=TEST_FILES.end(); ++it)
36 writeFileToZipOutputStream(zos, *it);
37 zos.close();
38
39 for(it=TEST_FILES.begin(); it!=TEST_FILES.end(); ++it)
40 assertEntry(TEST_ZIPFILE_NAME, *it);
41}
42
43void zipios::ZipOutputStreamTest::writeFileToZipOutputStream(ZipOutputStream& zos,
44 const string& entryName) {
45 CPPUNIT_FAIL("Implement this");
46}
47
48void zipios::ZipOutputStreamTest::assertEntry(const string& zipFileName,
49 const string& entryName) {
50 CPPUNIT_FAIL("Implement this");
51}
52
53bool zipios::ZipOutputStreamTest::hasUnzip() {
54 return system("unzip >/dev/null") == 0;
55}
56
57
58void zipios::ZipOutputStreamTest::entryToFile(const string &ent_name, istream &is,
59 const string &outfile,
60 bool cerr_report) {
61 ofstream ofs( outfile.c_str(), ios::out | ios::binary ) ;
62
63
64 ofs << is.rdbuf() ;
65 if ( cerr_report ) {
66 cerr << "writing " << ent_name << " to " << outfile << endl ;
67 cerr << "Stream state: " ;
68 cerr << "good() = " << is.good() << ",\t" ;
69 cerr << "fail() = " << is.fail() << ",\t" ;
70 cerr << "bad() = " << is.bad() << ",\t" ;
71 cerr << "eof() = " << is.eof() << endl << endl;
72 }
73 ofs.close() ;
74}
75
76
82/*
83 Zipios++ - a small C++ library that provides easy access to .zip files.
84 Copyright (C) 2000 Thomas Søndergaard
85
86 This library is free software; you can redistribute it and/or
87 modify it under the terms of the GNU Lesser General Public
88 License as published by the Free Software Foundation; either
89 version 2 of the License, or (at your option) any later version.
90
91 This library is distributed in the hope that it will be useful,
92 but WITHOUT ANY WARRANTY; without even the implied warranty of
93 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
94 Lesser General Public License for more details.
95
96 You should have received a copy of the GNU Lesser General Public
97 License along with this library; if not, write to the Free Software
98 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
99*/
100
101
ZipOutputStream is an ostream that writes the output to a zip file.
Header file that defines ZipOutputStream.