| 160 | } |
| 161 | |
| 162 | int FTPCache::ClearCurrentCache(bool permanent) { |
| 163 | SHFILEOPSTRUCT shfop; |
| 164 | TCHAR * dirPath = new TCHAR[MAX_PATH+1]; |
| 165 | |
| 166 | ZeroMemory(&shfop, sizeof(shfop)); |
| 167 | shfop.hwnd = _MainOutputWindow; |
| 168 | shfop.wFunc = FO_DELETE; |
| 169 | shfop.pFrom = dirPath; |
| 170 | shfop.pTo = NULL; |
| 171 | shfop.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_SILENT;// | FOF_WANTNUKEWARNING; |
| 172 | if (!permanent) { |
| 173 | shfop.fFlags |= FOF_ALLOWUNDO; //use recycle bin |
| 174 | } |
| 175 | shfop.lpszProgressTitle = NULL; |
| 176 | |
| 177 | |
| 178 | |
| 179 | for(size_t i = 0; i < m_vCachePaths.size(); i++) { |
| 180 | OutMsg("[Cache] Clearing cache in '%T'", m_vCachePaths[i].localpathExpanded); |
| 181 | lstrcpy(dirPath, m_vCachePaths[i].localpathExpanded); |
| 182 | int len = lstrlen(dirPath); |
| 183 | dirPath[len+1] = 0; |
| 184 | int res = SHFileOperation(&shfop); |
| 185 | if (res != 0) { |
| 186 | //Error may also be triggered if cache is empty, so stay silent |
| 187 | //OutErr("Failure clearing cache: %d", res); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | delete [] dirPath; |
| 192 | |
| 193 | if (m_cacheParent) |
| 194 | return m_cacheParent->ClearCurrentCache(permanent); |
| 195 | |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | TiXmlElement* FTPCache::SaveCache(const FTPCache * cache) { |
| 200 | TiXmlElement * cacheElem = new TiXmlElement(FTPCache::CacheElem); |