fixed bug causing call to closedir on invalid handle

This commit is contained in:
mr-alice 2016-09-24 13:56:02 +02:00
parent 96b333d67e
commit e03bd6cbac
2 changed files with 8 additions and 2 deletions

View File

@ -44,10 +44,10 @@ FolderIterator::FolderIterator(const std::string& folderName)
utf16Name += L"/*.*";
handle = FindFirstFileW(utf16Name.c_str(), &fileInfo);
validity = handle != INVALID_HANDLE_VALUE;
is_open = validity = handle != INVALID_HANDLE_VALUE;
#else
handle = opendir(folderName.c_str());
validity = handle != NULL;
is_open = validity = handle != NULL;
next();
#endif
}
@ -156,6 +156,11 @@ bool FolderIterator::closedir()
{
validity = false;
if(!is_open)
return true ;
is_open = false ;
#ifdef WINDOWS_SYS
return FindClose(handle) != 0;
#else

View File

@ -50,6 +50,7 @@ public:
time_t file_modtime() ;
private:
bool is_open;
bool validity;
#ifdef WINDOWS_SYS