zipios 2.3.4
Zipios -- a small C++ library providing easy access to .zip files.
zipinputstream.cpp
Go to the documentation of this file.
1/*
2 Zipios -- a small C++ library that provides easy access to .zip files.
3
4 Copyright (C) 2000-2007 Thomas Sondergaard
5 Copyright (c) 2015-2022 Made to Order Software Corp. All Rights Reserved
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
30#include "zipinputstream.hpp"
31
32#include <fstream>
33
34
35namespace zipios
36{
37
38
62ZipInputStream::ZipInputStream(std::string const & filename, std::streampos pos)
63 : std::istream(nullptr)
64 , m_ifs(std::make_unique<std::ifstream>(filename, std::ios::in | std::ios::binary))
65 , m_ifs_ref(*m_ifs)
66 , m_izf(std::make_unique<ZipInputStreambuf>(m_ifs_ref.rdbuf(), pos))
67{
68 // properly initialize the stream with the newly allocated buffer
69 init(m_izf.get());
70}
71
72
74 : std::istream(nullptr)
75 , m_ifs_ref(is)
76 , m_izf(std::make_unique<ZipInputStreambuf>(m_ifs_ref.rdbuf(), 0))
77{
78 // properly initialize the stream with the newly allocated buffer
79 init(m_izf.get());
80}
81
82
91
92
93} // zipios namespace
94
95// Local Variables:
96// mode: cpp
97// indent-tabs-mode: nil
98// c-basic-offset: 4
99// tab-width: 4
100// End:
101
102// vim: ts=4 sw=4 et
ZipInputStream(std::string const &filename, std::streampos pos=0)
Initialize a ZipInputStream from a filename and position.
virtual ~ZipInputStream() override
Clean up the input stream.
std::unique_ptr< ZipInputStreambuf > m_izf
An input stream buffer for Zip data.
The zipios namespace includes the Zipios library definitions.
Define zipios::ZipInputStream.