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 void setSize(uint32 size)
Sets the size field for the entry.
virtual ConstEntries entries() const
SimpleSmartPointer is a simple reference counting smart pointer template.
virtual ~DirectoryCollection()
Destructor.
vector< EntryPointer > ConstEntries
ConstEntries is a vector of ConstEntryPointer's.
Header file that defines DirectoryCollection.
BasicEntry is a FileEntry that is suitable as a base class for basic entries, that e...
virtual ConstEntryPointer getEntry(const string &name, MatchPath matchpath=MATCH) 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 int size() const
Returns the number of entries in the FileCollection.
virtual ConstEntryPointer getEntry(const string &name, MatchPath matchpath=MATCH) const
virtual ConstEntries entries() const
virtual FileCollection * clone() const
Create a heap allocated clone of the object this method is called for.
FilePath represents a path to a file or directory name.