From 46528b1f2981ebb387f770df47a9fd6000e3ef3b Mon Sep 17 00:00:00 2001 From: zvon Date: Mon, 7 Jan 2019 22:21:02 +0100 Subject: [PATCH] Add consts --- filesystem.cpp | 10 +++++----- filesystem.hpp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/filesystem.cpp b/filesystem.cpp index a7a1301..abca16b 100644 --- a/filesystem.cpp +++ b/filesystem.cpp @@ -57,7 +57,7 @@ const char *FSLib::Directory::path() const { return dir_path.c_str(); } -std::string FSLib::Directory::Iterator::operator*() { +char const *FSLib::Directory::Iterator::operator*() const { return current_entry->d_name; } @@ -65,8 +65,8 @@ FSLib::Directory::Iterator &FSLib::Directory::Iterator::operator++() { if( current_entry == nullptr ) return *this; current_entry = readdir(d); - if( current_entry != nullptr && (!strcmp(current_entry->d_name, ".") || !strcmp(current_entry->d_name, "..")) ) - operator++(); + if( current_entry != nullptr && ( !strcmp(current_entry->d_name, ".") || !strcmp(current_entry->d_name, "..") ) ) + return operator++(); return *this; } @@ -76,10 +76,10 @@ FSLib::Directory::Iterator FSLib::Directory::Iterator::operator++(int) { return ret; } -bool FSLib::Directory::Iterator::operator==(const Iterator &i_other) { +bool FSLib::Directory::Iterator::operator==(const Iterator &i_other) const { return i_other.current_entry == current_entry; } -bool FSLib::Directory::Iterator::operator!=(const Iterator &i_other) { +bool FSLib::Directory::Iterator::operator!=(const Iterator &i_other) const { return i_other.current_entry != current_entry; } diff --git a/filesystem.hpp b/filesystem.hpp index bbc8151..1c4a43e 100644 --- a/filesystem.hpp +++ b/filesystem.hpp @@ -36,15 +36,15 @@ namespace FSLib{ closedir(d); } - std::string operator*(); + char const *operator*() const; Iterator &operator++(); Iterator operator++(int); - bool operator==(const Iterator &i_other); + bool operator==(const Iterator &i_other) const; - bool operator!=(const Iterator &i_other); + bool operator!=(const Iterator &i_other) const; private: DIR *d;