From de2ef74938d9806744c71dd828d5e97012614f46 Mon Sep 17 00:00:00 2001 From: zvon Date: Mon, 11 May 2020 14:46:27 +0200 Subject: [PATCH] filesystem: fix windows directory iteration --- filesystem.hpp | 6 ++++++ windows/filesystem.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/filesystem.hpp b/filesystem.hpp index 5477673..4e44d63 100644 --- a/filesystem.hpp +++ b/filesystem.hpp @@ -108,6 +108,12 @@ public: return dir_path.c_str(); } +#ifdef _WIN32 + const char_t *validPath() const { + return dir_path.substr(0, dir_path.length()-2).c_str(); + } +#endif + private: string dir_path; }; diff --git a/windows/filesystem.cpp b/windows/filesystem.cpp index 43d37f2..2a11abc 100644 --- a/windows/filesystem.cpp +++ b/windows/filesystem.cpp @@ -10,7 +10,7 @@ FSLib::Directory::Directory( const string &path_ ) : dir_path( path_ ) { } FSLib::Directory::Iterator::Iterator( const Directory &d_ ) { - if ( !exists( d_.path() ) || !isDirectory( d_.path() ) ) { + if ( !exists( d_.validPath() ) || !isDirectory( d_.validPath() ) ) { throw std::runtime_error( "Directory either doesn't exist or isn't a directory" ); }