| 219 | } |
| 220 | |
| 221 | bool FileSystemManager::deleteFiles(vector<FileSystemActor *> objList, vector<FileSystemActor *> &failedObj, bool confirm, bool skipRecycleBin) |
| 222 | { |
| 223 | if (objList.empty()) |
| 224 | return true; |
| 225 | |
| 226 | FileSystemActor *data; |
| 227 | SHFILEOPSTRUCT fileOperation = { 0 }; |
| 228 | vector<FileSystemActor *> delList; |
| 229 | int numVirtualIconsDeleted = 0; |
| 230 | |
| 231 | TCHAR * fromPaths = allocateStringFromPathsArray(objList); |
| 232 | TCHAR * fromPathsOffset = fromPaths; |
| 233 | |
| 234 | // build the paths of files to delete |
| 235 | for (int i = 0; i < objList.size(); i++) |
| 236 | { |
| 237 | // Check if its a filesystem actor |
| 238 | if (objList[i]->getObjectType() == ObjectType(BumpActor, FileSystem)) |
| 239 | { |
| 240 | data = (FileSystemActor *) objList[i]; |
| 241 | |
| 242 | // Exclude Virtual folders |
| 243 | if (!data->isFileSystemType(Virtual)) |
| 244 | { |
| 245 | // Check to see if this file is actually on the hard disk or not |
| 246 | if (isValidFileName(data->getFullPath())) |
| 247 | { |
| 248 | // build the from-path string |
| 249 | lstrcpy(fromPathsOffset, (LPCTSTR) data->getFullPath().utf16()); |
| 250 | fromPathsOffset += data->getFullPath().size() + 1; |
| 251 | |
| 252 | delList.push_back(data); |
| 253 | } |
| 254 | } |
| 255 | else |
| 256 | { |
| 257 | // prompt the user |
| 258 | dlgManager->clearState(); |
| 259 | dlgManager->setCaption(QT_TR_NOOP("Remove from desktop?")); |
| 260 | dlgManager->setPrompt(QT_TR_NOOP("Are you sure you want to remove %1 from your desktop?\n(You can re-enable it in Windows' Desktop Properties dialog)").arg(data->getFullPath())); |
| 261 | if (dlgManager->promptDialog(DialogYesNo)) |
| 262 | { |
| 263 | // we try and set the associated registry values for these icons |
| 264 | winOS->SetIconAvailability(winOS->GetIconTypeFromFileName(data->getFullPath()), false); |
| 265 | // but fade and delete the actor anyways |
| 266 | FadeAndDeleteActor(data); |
| 267 | } |
| 268 | ++numVirtualIconsDeleted; |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | if ((delList.size() + numVirtualIconsDeleted) != objList.size()) |
| 274 | { |
| 275 | // Alert the user that one of more VIRTUAL files are in the selection |
| 276 | MessageClearPolicy clearPolicy; |
| 277 | clearPolicy.setTimeout(4); |
| 278 | scnManager->messages()->addMessage(new Message("deleteFiles", QT_TR_NOOP("Some items cannot be deleted (ie. My Computer, Recycle Bin)\nPlease remove them through Windows' Desktop properties"), Message::Warning, clearPolicy)); |
no test coverage detected