concat path error (#19075)

when trying to remove dir `test0`, the function will build a pattern
like `"test0*.*"` rather than `test0/*.*`
This commit is contained in:
Arnold 2018-10-08 11:51:36 +08:00 committed by minggo
parent 11339c4545
commit 1ceb222c7f
1 changed files with 6 additions and 1 deletions

View File

@ -479,7 +479,12 @@ bool FileUtilsWin32::removeFile(const std::string &filepath) const
bool FileUtilsWin32::removeDirectory(const std::string& dirPath) const
{
std::wstring wpath = StringUtf8ToWideChar(dirPath);
std::string dirPathCopy = dirPath;
if (dirPath.length() > 0 && dirPath[dirPath.length() - 1] != '/' && dirPath[dirPath.length() - 1] != '\\')
{
dirPathCopy.append("/");
}
std::wstring wpath = StringUtf8ToWideChar(dirPathCopy);
std::wstring files = wpath + L"*.*";
WIN32_FIND_DATA wfd;
HANDLE search = FindFirstFileEx(files.c_str(), FindExInfoStandard, &wfd, FindExSearchNameMatch, NULL, 0);