MCPcopy Create free account
hub / github.com/bumptop/BumpTop / deleteFiles

Method deleteFiles

trunk/win/Source/BT_FileSystemManager.cpp:221–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221bool 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));

Callers 3

onDropMethod · 0.45
breakPileMethod · 0.45
pDeleteSelectionFunction · 0.45

Calls 15

ObjectTypeClass · 0.85
FadeAndDeleteActorFunction · 0.85
isFileSystemTypeMethod · 0.80
getFullPathMethod · 0.80
clearStateMethod · 0.80
setCaptionMethod · 0.80
setPromptMethod · 0.80
promptDialogMethod · 0.80
SetIconAvailabilityMethod · 0.80
addMessageMethod · 0.80
messagesMethod · 0.80

Tested by

no test coverage detected