From 9e3b14d9dcb3358590eedab847c892133a59db1b Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sun, 3 Feb 2019 14:43:54 +0900 Subject: [PATCH] TempFile.cpp: Use Poco::File::remove() instead of SHFileOperation() SHFileOperation() is slow. --HG-- branch : stable --- Src/TempFile.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Src/TempFile.cpp b/Src/TempFile.cpp index cbe50d981..3edd49651 100644 --- a/Src/TempFile.cpp +++ b/Src/TempFile.cpp @@ -218,16 +218,13 @@ static bool WMrunning(const vector& processIDs, int iPI) */ bool ClearTempfolder(const String &pathName) { - // SHFileOperation expects a ZZ terminated list of paths! - String normalizedPathName = pathName; - paths::normalize(normalizedPathName); // remove trailing slash - const size_t pathSize = normalizedPathName.length() + 2; - std::vector path(pathSize, 0); - memcpy(&path[0], normalizedPathName.c_str(), normalizedPathName.length() * sizeof(TCHAR)); - - SHFILEOPSTRUCT fileop = {0, FO_DELETE, &path[0], 0, FOF_NOCONFIRMATION | - FOF_SILENT | FOF_NOERRORUI, 0, 0, 0}; - SHFileOperation(&fileop); - + try + { + TFile(pathName).remove(true); + } + catch (...) + { + return false; + } return true; } -- 2.11.0