Rename Dir to DirIterator

This commit is contained in:
Robert Knight 2011-08-24 11:53:02 +01:00
parent 887619f239
commit b4311d79a9
4 changed files with 14 additions and 14 deletions

View File

@ -21,7 +21,7 @@ endif()
add_definitions(-DTIXML_USE_STL) add_definitions(-DTIXML_USE_STL)
set (SOURCES set (SOURCES
Dir.cpp DirIterator.cpp
FileOps.cpp FileOps.cpp
Log.cpp Log.cpp
ProcessUtils.cpp ProcessUtils.cpp
@ -41,7 +41,7 @@ if (WIN32)
endif() endif()
set (HEADERS set (HEADERS
Dir.h DirIterator.h
FileOps.h FileOps.h
Log.h Log.h
ProcessUtils.h ProcessUtils.h

View File

@ -1,4 +1,4 @@
#include "Dir.h" #include "DirIterator.h"
#include "Log.h" #include "Log.h"
#include "StringUtils.h" #include "StringUtils.h"
@ -15,7 +15,7 @@ bool endsWith(const std::string& str, const char* text)
return str.find(text,str.size() - length) != 0; return str.find(text,str.size() - length) != 0;
} }
Dir::Dir(const char* path) DirIterator::DirIterator(const char* path)
{ {
m_path = path; m_path = path;
@ -37,7 +37,7 @@ Dir::Dir(const char* path)
#endif #endif
} }
Dir::~Dir() DirIterator::~DirIterator()
{ {
#ifdef PLATFORM_UNIX #ifdef PLATFORM_UNIX
closedir(m_dir); closedir(m_dir);
@ -46,7 +46,7 @@ Dir::~Dir()
#endif #endif
} }
bool Dir::next() bool DirIterator::next()
{ {
#ifdef PLATFORM_UNIX #ifdef PLATFORM_UNIX
m_entry = readdir(m_dir); m_entry = readdir(m_dir);
@ -66,7 +66,7 @@ bool Dir::next()
#endif #endif
} }
std::string Dir::fileName() const std::string DirIterator::fileName() const
{ {
#ifdef PLATFORM_UNIX #ifdef PLATFORM_UNIX
return m_entry->d_name; return m_entry->d_name;
@ -75,12 +75,12 @@ std::string Dir::fileName() const
#endif #endif
} }
std::string Dir::filePath() const std::string DirIterator::filePath() const
{ {
return m_path + '/' + fileName(); return m_path + '/' + fileName();
} }
bool Dir::isDir() const bool DirIterator::isDir() const
{ {
#ifdef PLATFORM_UNIX #ifdef PLATFORM_UNIX
return m_entry->d_type == DT_DIR; return m_entry->d_type == DT_DIR;

View File

@ -8,11 +8,11 @@
#include <dirent.h> #include <dirent.h>
#endif #endif
class Dir class DirIterator
{ {
public: public:
Dir(const char* path); DirIterator(const char* path);
~Dir(); ~DirIterator();
// iterate to the next entry in the directory // iterate to the next entry in the directory
bool next(); bool next();

View File

@ -1,6 +1,6 @@
#include "FileOps.h" #include "FileOps.h"
#include "Dir.h" #include "DirIterator.h"
#include "Log.h" #include "Log.h"
#include "Platform.h" #include "Platform.h"
#include "StringUtils.h" #include "StringUtils.h"
@ -266,7 +266,7 @@ void FileOps::touch(const char* path) throw (IOException)
void FileOps::rmdirRecursive(const char* path) throw (IOException) void FileOps::rmdirRecursive(const char* path) throw (IOException)
{ {
// remove dir contents // remove dir contents
Dir dir(path); DirIterator dir(path);
while (dir.next()) while (dir.next())
{ {
std::string name = dir.fileName(); std::string name = dir.fileName();