30#if !defined(ZIPIOS_WINDOWS) && (defined(_WINDOWS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32))
93 std::string
const & path
95 : m_recursive(recursive)
206 if(ent ==
nullptr || ent->isDirectory())
225 return std::make_shared<DirectoryCollection>(*
this);
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 !=
"..")
A collection generated from reading a directory.
virtual FileEntry::vector_t entries() const override
Retrieve a vector to the collection entries.
virtual ~DirectoryCollection() override
Clean up a DirectoryCollection object.
void load(FilePath const &subdir)
This is the function loading all the file entries.
virtual pointer_t clone() const override
Create another DirectoryCollection.
DirectoryCollection()
Initialize a DirectoryCollection object.
virtual stream_pointer_t getInputStream(std::string const &entry_name, MatchPath matchpath=MatchPath::MATCH) override
Retrieve pointer to an istream.
virtual void close() override
Close the directory collection.
virtual FileEntry::pointer_t getEntry(std::string const &name, MatchPath matchpath=MatchPath::MATCH) const override
Get an entry from the collection.
void loadEntries() const
This is an internal function that loads the file entries.
virtual FileEntry::pointer_t getEntry(std::string const &name, MatchPath matchpath=MatchPath::MATCH) const
Get an entry from this collection.
std::shared_ptr< FileCollection > pointer_t
virtual void mustBeValid() const
Check whether the collection is valid.
std::shared_ptr< std::istream > stream_pointer_t
A shared pointer to an input stream.
virtual void close()
Close the current FileEntry of this FileCollection.
FileEntry::vector_t m_entries
virtual FileEntry::vector_t entries() const
Retrieve the array of entries.
std::shared_ptr< FileEntry > pointer_t
std::vector< pointer_t > vector_t
Handle a file path and name and its statistics.
void clear()
Clear the filename.
bool isDirectory() const
Check whether the file is a directory.
bool isRegular() const
Check whether the file is a regular file.
An IOException is used to signal an I/O error.
Define the zipios::DirectoryCollection class.
The zipios namespace includes the Zipios library definitions.
Various exceptions used throughout the Zipios library, all based on zipios::Exception.