30 #if !defined(ZIPIOS_WINDOWS) && (defined(_WINDOWS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32)) 31 #define ZIPIOS_WINDOWS 93 std::string
const & path
95 : m_recursive(recursive)
206 if(ent ==
nullptr || ent->isDirectory())
225 return std::make_shared<DirectoryCollection>(*this);
280 #ifdef ZIPIOS_WINDOWS 290 m_handle = _findfirsti64(static_cast<std::string>(path).c_str(), &m_fileinfo);
301 throw IOException(
"an I/O error occurred while reading a directory");
312 _findclose(m_handle);
320 __int64
const r(_findnexti64(m_handle, &m_fileinfo));
325 throw IOException(
"an I/O error occurred while reading a directory");
327 return std::string();
336 return m_fileinfo.name;
341 struct _finddatai64_t m_fileinfo = {};
342 bool m_read_first = 0;
348 : m_dir(opendir(static_cast<std::string>(path).c_str()))
352 throw IOException(
"an I/O error occurred while trying to access directory");
370 struct dirent * entry(readdir(m_dir));
375 throw IOException(
"an I/O error occurred while reading a directory");
377 return std::string();
380 return entry->d_name;
384 DIR * m_dir =
nullptr;
391 std::string
const & name(dir.next());
399 if(name !=
"." && name !=
"..")
virtual FileEntry::pointer_t getEntry(std::string const &name, MatchPath matchpath=MatchPath::MATCH) const
Get an entry from this collection.
The zipios namespace includes the Zipios library definitions.
std::shared_ptr< FileCollection > pointer_t
virtual FileEntry::vector_t entries() const override
Retrieve a vector to the collection entries.
Various exceptions used throughout the Zipios library, all based on zipios::Exception.
void clear()
Clear the filename.
std::shared_ptr< std::istream > stream_pointer_t
A shared pointer to an input stream.
Define the zipios::DirectoryCollection class.
A collection generated from reading a directory.
virtual FileEntry::vector_t entries() const
Retrieve the array of entries.
virtual void close() override
Close the directory collection.
virtual pointer_t clone() const override
Create another DirectoryCollection.
DirectoryCollection()
Initialize a DirectoryCollection object.
FileEntry::vector_t m_entries
bool isDirectory() const
Check whether the file is a directory.
An IOException is used to signal an I/O error.
virtual void close()
Close the current FileEntry of this FileCollection.
void load(FilePath const &subdir)
This is the function loading all the file entries.
virtual void mustBeValid() const
Check whether the collection is valid.
void loadEntries() const
This is an internal function that loads the file entries.
bool isRegular() const
Check whether the file is a regular file.
Handle a file path and name and its statistics.
virtual ~DirectoryCollection() override
Clean up a DirectoryCollection object.
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
std::vector< pointer_t > vector_t