]> git.donarmstrong.com Git - flightcrew.git/blob - src/zipios/zipios++/dircoll.h
Imported Upstream version 0.7.2+dfsg
[flightcrew.git] / src / zipios / zipios++ / dircoll.h
1 #ifndef DIRCOLL_H
2 #define DIRCOLL_H
3
4 #include "zipios++/zipios-config.h"
5
6
7 #include "zipios++/fcoll.h"
8 #include "zipios++/basicentry.h"
9 #include "zipios++/filepath.h"
10
11 namespace zipios {
12
13 /** DirEntry is a BasicEntry. */
14 typedef BasicEntry DirEntry ;
15
16 /** \anchor dircol_anchor
17     DirectoryCollection is a FileCollection that obtains its entries
18     from a directory. */
19 class DirectoryCollection : public FileCollection {
20 public:
21
22   /** Default Constructor. */
23   explicit DirectoryCollection() 
24     : _entries_loaded( false ), _recursive( true ) {}
25
26
27   /** Constructor.
28       @param path A directory path name. If the name is not a valid
29       directory the created DirectoryCollection will be invalid.
30       @param load_now Load directory into memory now. Otherwise it will
31       be done when it is first needed.
32   */
33   explicit DirectoryCollection( const string &path, 
34                                 bool recursive = true,
35                                 bool load_now = false ) ;
36
37   /* Default Copy constructor and copy assignment operator are sufficient. */
38
39   virtual void close() ;
40
41   virtual ConstEntries entries() const ;
42
43   virtual ConstEntryPointer getEntry( const string &name, 
44                                      MatchPath matchpath = MATCH ) const ;
45
46   virtual istream *getInputStream( const ConstEntryPointer &entry ) ;
47
48   virtual istream *getInputStream( const string &entry_name, 
49                                      MatchPath matchpath = MATCH ) ;
50
51   virtual int size() const ;
52
53   virtual FileCollection *clone() const ;
54
55   /** Destructor. */
56   virtual ~DirectoryCollection() ;
57
58 protected:
59   mutable bool _entries_loaded ;
60   bool _recursive ; // recurse into subdirs.
61   FilePath _filepath ;
62
63   void loadEntries() const ;
64   void load( bool recursive, const FilePath &subdir = FilePath() ) ;
65  
66 };
67  
68 } // namespace
69
70 #endif
71
72 /** \file
73     Header file that defines DirectoryCollection.
74 */
75
76 /*
77   Zipios++ - a small C++ library that provides easy access to .zip files.
78   Copyright (C) 2000  Thomas Søndergaard
79   
80   This library is free software; you can redistribute it and/or
81   modify it under the terms of the GNU Lesser General Public
82   License as published by the Free Software Foundation; either
83   version 2 of the License, or (at your option) any later version.
84   
85   This library is distributed in the hope that it will be useful,
86   but WITHOUT ANY WARRANTY; without even the implied warranty of
87   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
88   Lesser General Public License for more details.
89   
90   You should have received a copy of the GNU Lesser General Public
91   License along with this library; if not, write to the Free Software
92   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
93 */