From 995a4527da59c2c0cd236a8f42685c69d6cbbe73 Mon Sep 17 00:00:00 2001 From: KimLS Date: Sat, 10 Jun 2017 22:23:27 -0700 Subject: [PATCH] Some changes to directory code to help it compile on newer gcc compilers --- common/util/directory.cpp | 21 ++++++++++++++------- common/util/directory.h | 5 ++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common/util/directory.cpp b/common/util/directory.cpp index 557a7a006..9bc075bbe 100644 --- a/common/util/directory.cpp +++ b/common/util/directory.cpp @@ -6,28 +6,35 @@ #include #endif +struct EQ::Directory::impl { + DIR *m_dir; +}; + EQ::Directory::Directory(const std::string &path) { - m_dir = opendir(path.c_str()); + m_impl = new impl; + m_impl->m_dir = opendir(path.c_str()); } EQ::Directory::~Directory() { - if (m_dir) { - closedir(m_dir); + if (m_impl->m_dir) { + closedir(m_impl->m_dir); } + + delete m_impl; } bool EQ::Directory::Exists() { - return m_dir != nullptr; + return m_impl->m_dir != nullptr; } void EQ::Directory::GetFiles(std::vector& files) { - if (m_dir) { + if (m_impl->m_dir) { struct dirent *ent; - while ((ent = readdir(m_dir)) != nullptr) { + while ((ent = readdir(m_impl->m_dir)) != nullptr) { switch (ent->d_type) { case DT_REG: files.push_back(ent->d_name); @@ -37,6 +44,6 @@ void EQ::Directory::GetFiles(std::vector& files) } } - rewinddir(m_dir); + rewinddir(m_impl->m_dir); } } diff --git a/common/util/directory.h b/common/util/directory.h index aa4cc9ecb..d5f7441b2 100644 --- a/common/util/directory.h +++ b/common/util/directory.h @@ -3,8 +3,6 @@ #include #include -struct DIR; - namespace EQ { class Directory { @@ -15,6 +13,7 @@ namespace EQ { bool Exists(); void GetFiles(std::vector &files); private: - DIR *m_dir; + struct impl; + impl *m_impl; }; }