WSL/SLF GitLab Repository

Commit 324a3b0c authored by Mathias Bavay's avatar Mathias Bavay
Browse files

On some Windows versions, reading a directory was failing, simply reporting...

On some Windows versions, reading a directory was failing, simply reporting "could not open directory". This seems to have been dependent on the character encoding of the system. This has been solved by forcing the use of ANSI calls for the Win API.
parent 1db5bb38
......@@ -176,14 +176,13 @@ bool fileExists(const std::string& filename)
void readDirectory(const std::string& path, std::list<std::string>& dirlist, const std::string& pattern)
{
const size_t path_length = path.length();
if (path_length > (MAX_PATH - 3)) {
if (path_length > (MAX_PATH - 1)) {
std::cerr << "Path " << path << "is too long (" << path_length << " characters)" << std::endl;
throw FileAccessException("Error opening directory " + path, AT);
}
const std::string filepath = path+"\\";
WIN32_FIND_DATA ffd;
const HANDLE hFind = FindFirstFile(filepath.c_str(), &ffd);
const HANDLE hFind = FindFirstFileA(path.c_str(), &ffd);
if (INVALID_HANDLE_VALUE == hFind) {
throw FileAccessException("Error opening directory " + path, AT);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment