zipios++  2.0.2
Zipios++ – a small C++ library that provides easy access to .zip files.
directorycollection.hpp
Go to the documentation of this file.
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 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25 
35 
36 
37 namespace zipios
38 {
39 
40 
42 {
43 public:
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  virtual size_t size() const override;
54 
55 protected:
56  void loadEntries() const;
57  void load(FilePath const& subdir);
58 
59  mutable bool m_entries_loaded = false;
60  bool m_recursive = true;
62 };
63 
64 
65 } // zipios namespace
66 
67 // Local Variables:
68 // mode: cpp
69 // indent-tabs-mode: nil
70 // c-basic-offset: 4
71 // tab-width: 4
72 // End:
73 
74 // vim: ts=4 sw=4 et
75 #endif
std::shared_ptr< FileCollection > pointer_t
virtual FileEntry::vector_t entries() const override
Retrieve a vector to the collection entries.
void loadEntries() const
This is an internal function that loads the file entries.
std::shared_ptr< std::istream > stream_pointer_t
A shared pointer to an input stream.
A collection generated from reading a directory.
Define the zipios::FileCollection class.
virtual size_t size() const override
Return the number of entries defined in this collection.
virtual void close() override
Close the directory collection.
virtual pointer_t clone() const override
Create another DirectoryCollection.
DirectoryCollection()
Initialize a DirectoryCollection object.
Define the zipios::DirectoryEntry class.
void load(FilePath const &subdir)
This is the function loading all the file entries.
Handle a file path and name and its statistics.
Definition: filepath.hpp:46
virtual ~DirectoryCollection() override
Clean up a DirectoryCollection object.
Base class for various file collections.
virtual stream_pointer_t getInputStream(std::string const &entry_name, MatchPath matchpath=MatchPath::MATCH) override
Retrieve pointer to an istream.
virtual FileEntry::pointer_t getEntry(std::string const &name, MatchPath matchpath=MatchPath::MATCH) const override
Get an entry from the collection.
std::shared_ptr< FileEntry > pointer_t
Definition: fileentry.hpp:77
std::vector< pointer_t > vector_t
Definition: fileentry.hpp:78