From 1ceb222c7fdb09f1c89b13baa1f7c401f6e93484 Mon Sep 17 00:00:00 2001 From: Arnold <40414978+PatriceJiang@users.noreply.github.com> Date: Mon, 8 Oct 2018 11:51:36 +0800 Subject: [PATCH] concat path error (#19075) when trying to remove dir `test0`, the function will build a pattern like `"test0*.*"` rather than `test0/*.*` --- cocos/platform/win32/CCFileUtils-win32.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos/platform/win32/CCFileUtils-win32.cpp b/cocos/platform/win32/CCFileUtils-win32.cpp index 9b97bd7efa..42480c2c50 100644 --- a/cocos/platform/win32/CCFileUtils-win32.cpp +++ b/cocos/platform/win32/CCFileUtils-win32.cpp @@ -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);