2 #include "zipios++/zipios-config.h"
4 #include "zipios++/meta-iostreams.h"
10 #include "directory.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() ;
121 void DirectoryCollection::loadEntries()
const {
122 if( _entries_loaded )
127 _entries_loaded = true ;
131 void 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 ) ) ;
virtual FileCollection * clone() const
Create a heap allocated clone of the object this method is called for.
SimpleSmartPointer is a simple reference counting smart pointer template.
virtual ~DirectoryCollection()
Destructor.
virtual ConstEntries entries() const
Header file that defines DirectoryCollection.
BasicEntry is a FileEntry that is suitable as a base class for basic entries, that e...
virtual int size() const
Returns the number of entries in the FileCollection.
virtual ConstEntries entries() const
virtual istream * getInputStream(const ConstEntryPointer &entry)
virtual void close()
Closes the FileCollection.
DirectoryCollection()
Default Constructor.
An object member function may throw this exception, if the operation it normally performs is inapprop...
virtual ConstEntryPointer getEntry(const string &name, MatchPath matchpath=MATCH) const
virtual ConstEntryPointer getEntry(const string &name, MatchPath matchpath=MATCH) const