mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2024-11-26 22:01:39 +00:00
Fix dir iteration on Windows
Instead of passing the directory to FindFirstFile(), a wildcard of the form C:\Path\To\Dir\* needs to be passed.
This commit is contained in:
parent
66dc8d4720
commit
57e13d941b
2 changed files with 20 additions and 1 deletions
20
src/Dir.cpp
20
src/Dir.cpp
|
@ -1,9 +1,18 @@
|
|||
#include "Dir.h"
|
||||
|
||||
#include "Log.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#ifdef PLATFORM_UNIX
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
bool endsWith(const std::string& str, const char* text)
|
||||
{
|
||||
int length = strlen(text);
|
||||
return str.find(text,str.size() - length) != 0;
|
||||
}
|
||||
|
||||
Dir::Dir(const char* path)
|
||||
{
|
||||
m_path = path;
|
||||
|
@ -11,7 +20,16 @@ Dir::Dir(const char* path)
|
|||
#ifdef PLATFORM_UNIX
|
||||
m_dir = opendir(path);
|
||||
#else
|
||||
m_findHandle = FindFirstFile(path,&m_findData);
|
||||
// to list the contents of a directory, the first
|
||||
// argument to FindFirstFile needs to be a wildcard
|
||||
// of the form: C:\path\to\dir\*
|
||||
std::string searchPath = m_path;
|
||||
if (!endsWith(searchPath,"/"))
|
||||
{
|
||||
searchPath.append("/");
|
||||
}
|
||||
searchPath.append("*");
|
||||
m_findHandle = FindFirstFile(searchPath.c_str(),&m_findData);
|
||||
m_firstEntry = true;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "FileOps.h"
|
||||
|
||||
#include "Dir.h"
|
||||
#include "Log.h"
|
||||
#include "Platform.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue