2#include "zipios++/zipios-config.h"
4#include "zipios++/meta-iostreams.h"
22 : _entries_loaded( false ),
23 _recursive ( recursive ),
26 _filename = _filepath ;
29 if( _valid && load_now )
50 MatchPath matchpath )
const {
54 if ( matchpath != MATCH || _entries_loaded ) {
77 MatchPath matchpath ) {
81 if ( matchpath != MATCH || _entries_loaded ) {
89 string real_path( _filepath + entry_name ) ;
90 return new ifstream( real_path.c_str(), ios::in | ios::binary ) ;
95 string real_path( _filepath + entry_name ) ;
96 ifstream *ifs =
new ifstream( real_path.c_str(), ios::in | ios::binary ) ;
111 return _entries.size() ;
121void DirectoryCollection::loadEntries()
const {
122 if( _entries_loaded )
127 _entries_loaded = true ;
131void DirectoryCollection::load(
bool recursive,
const FilePath &subdir ) {
132 using namespace boost::filesystem ;
134 for ( dir_it it( _filepath + subdir ) ; it != dir_it() ; ++it ) {
136 if ( *it ==
"." || *it ==
".." || *it ==
"..." )
139 if ( get< is_directory >( it ) && recursive ) {
140 load( recursive, subdir + *it ) ;
142 _entries.push_back( ent =
new BasicEntry( subdir + *it,
"", _filepath ) ) ;
143 ent->setSize( get< boost::filesystem::size >( it ) ) ;
BasicEntry is a FileEntry that is suitable as a base class for basic entries, that e....
DirectoryCollection is a FileCollection that obtains its entries from a directory.
virtual ConstEntryPointer getEntry(const string &name, MatchPath matchpath=MATCH) const
Returns a ConstEntryPointer to a FileEntry object for the entry with the specified name.
virtual istream * getInputStream(const ConstEntryPointer &entry)
Returns a pointer to an opened istream for the specified FileEntry.
virtual FileCollection * clone() const
Create a heap allocated clone of the object this method is called for.
virtual void close()
Closes the FileCollection.
DirectoryCollection()
Default Constructor.
virtual ~DirectoryCollection()
Destructor.
virtual int size() const
Returns the number of entries in the FileCollection.
virtual ConstEntries entries() const
Returns a vector of const pointers to the entries in the FileCollection.
FileCollection is an abstract baseclass that represents a collection of files.
virtual ConstEntryPointer getEntry(const string &name, MatchPath matchpath=MATCH) const
Returns a ConstEntryPointer to a FileEntry object for the entry with the specified name.
virtual ConstEntries entries() const
Returns a vector of const pointers to the entries in the FileCollection.
An object member function may throw this exception, if the operation it normally performs is inapprop...
SimpleSmartPointer is a simple reference counting smart pointer template.
Header file that defines DirectoryCollection.
vector< EntryPointer > ConstEntries
ConstEntries is a vector of ConstEntryPointer's.