MCPcopy Create free account
hub / github.com/WinMerge/winmerge / CleanupWMtemp

Function CleanupWMtemp

Src/TempFile.cpp:120–141  ·  view source on GitHub ↗

* @brief Cleanup tempfiles created by WinMerge. * This function finds temp folders which don't have WinMerge instance using * them anymore. */

Source from the content-addressed store, hash-verified

118 * them anymore.
119 */
120void CleanupWMtemp()
121{
122 DirItemArray dirs, files;
123 DirTravel::LoadFiles(paths::GetParentPath(env::GetTemporaryPath()), &dirs, &files, String(TempFolderPrefix) + _T("*"));
124
125 for (auto& dir : dirs)
126 {
127 const String foldername = dir.filename;
128 // Remove leading "WM_" from filename to get the ProcessID
129 const String tempfolderPID = foldername.substr(tc::tcslen(TempFolderPrefix));
130 // Check if this instance of WM is still running
131 try
132 {
133 int pid = atoi(ucr::toUTF8(tempfolderPID).c_str());
134 if (!WMrunning(pid))
135 ClearTempfolder(paths::ConcatPath(dir.path, foldername));
136 }
137 catch (...)
138 {
139 }
140 }
141}
142
143/**
144 * @brief Is WinMerge with given processID running?

Callers 1

ExitInstanceMethod · 0.85

Calls 7

LoadFilesFunction · 0.85
GetParentPathFunction · 0.85
GetTemporaryPathFunction · 0.85
WMrunningFunction · 0.85
ClearTempfolderFunction · 0.85
ConcatPathFunction · 0.85
toUTF8Function · 0.50

Tested by

no test coverage detected