Line data Source code
1 : #pragma once
2 : #ifndef ZIPIOS_DIRECTORYCOLLECTION_HPP
3 : #define ZIPIOS_DIRECTORYCOLLECTION_HPP
4 :
5 : /*
6 : Zipios -- a small C++ library that provides easy access to .zip files.
7 :
8 : Copyright (C) 2000-2007 Thomas Sondergaard
9 : Copyright (C) 2015-2019 Made to Order Software Corporation
10 :
11 : This library is free software; you can redistribute it and/or
12 : modify it under the terms of the GNU Lesser General Public
13 : License as published by the Free Software Foundation; either
14 : version 2.1 of the License, or (at your option) any later version.
15 :
16 : This library is distributed in the hope that it will be useful,
17 : but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 : Lesser General Public License for more details.
20 :
21 : You should have received a copy of the GNU Lesser General Public
22 : License along with this library; if not, write to the Free Software
23 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 : */
25 :
26 : /** \file
27 : * \brief Define the zipios::DirectoryCollection class.
28 : *
29 : * The zipios::DirectoryCollection class is used to handle a collection
30 : * of files as found in a directory on disk.
31 : */
32 :
33 : #include "zipios/filecollection.hpp"
34 : #include "zipios/directoryentry.hpp"
35 :
36 :
37 : namespace zipios
38 : {
39 :
40 :
41 92 : class DirectoryCollection : public FileCollection
42 : {
43 : public:
44 : DirectoryCollection();
45 : DirectoryCollection(std::string const& path, bool recursive = true);
46 : virtual pointer_t clone() const override;
47 : virtual ~DirectoryCollection() override;
48 :
49 : virtual void close() override;
50 : virtual FileEntry::vector_t entries() const override;
51 : virtual FileEntry::pointer_t getEntry(std::string const& name, MatchPath matchpath = MatchPath::MATCH) const override;
52 : virtual stream_pointer_t getInputStream(std::string const& entry_name, MatchPath matchpath = MatchPath::MATCH) override;
53 :
54 : protected:
55 : void loadEntries() const;
56 : void load(FilePath const& subdir);
57 :
58 : mutable bool m_entries_loaded = false;
59 : bool m_recursive = true;
60 : FilePath m_filepath;
61 : };
62 :
63 :
64 : } // zipios namespace
65 :
66 : // Local Variables:
67 : // mode: cpp
68 : // indent-tabs-mode: nil
69 : // c-basic-offset: 4
70 : // tab-width: 4
71 : // End:
72 :
73 : // vim: ts=4 sw=4 et
74 : #endif
|