MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / OnDeleteFile

Method OnDeleteFile

editor/FilePageDialog.cpp:292–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292void CFilePageDialog::OnDeleteFile() {
293 int n;
294 int answer, tl;
295 mngs_Pagelock pl;
296
297 if (Num_gamefiles < 1)
298 return;
299
300 int *listbox_map;
301 int listbox_count = CreateIndexMap(&listbox_map, IDC_CHECKEDOUT_LIST);
302 if (!listbox_count)
303 return;
304
305 if (!mng_MakeLocker()) {
306 mem_free(listbox_map);
307 return;
308 }
309
310 CCheckListBox *list = (CCheckListBox *)GetDlgItem(IDC_CHECKEDOUT_LIST);
311 char buffer[_MAX_PATH];
312
313 for (int i = 0; i < listbox_count; i++) {
314 list->GetText(listbox_map[i], buffer);
315 n = FindGameFile(buffer);
316 if (n == -1)
317 continue;
318
319 // Check to see if we even have it locked
320 if ((tl = mng_FindTrackLock(Gamefiles[n].name, PAGETYPE_GAMEFILE)) == -1) {
321 OutrageMessageBox("This gamefile is not yours to delete. Lock first.");
322 continue;
323 }
324
325 // Make sure its to be deleted
326 answer = MessageBox("Are you sure you want to delete this gamefile?", Gamefiles[n].name, MB_YESNO);
327 if (answer == IDNO)
328 continue;
329
330 strcpy(pl.name, Gamefiles[n].name);
331 pl.pagetype = PAGETYPE_GAMEFILE;
332
333 // Check to see if this is a local gamefile only. If so, only delete it locally
334 if (mng_CheckIfPageOwned(&pl, TableUser) != 1) {
335 mng_FreeTrackLock(tl);
336 if (!mng_DeletePage(Gamefiles[n].name, PAGETYPE_GAMEFILE, 1)) {
337 mprintf(0, ErrorString);
338 Int3();
339 }
340 } else // if its network, delete it from both the net and local drives
341 {
342
343 mng_FreeTrackLock(tl);
344 mng_DeletePage(Gamefiles[n].name, PAGETYPE_GAMEFILE, 1);
345 mng_DeletePage(Gamefiles[n].name, PAGETYPE_GAMEFILE, 0);
346 mng_DeletePagelock(Gamefiles[n].name, PAGETYPE_GAMEFILE);
347 }
348
349 FreeGamefile(n);

Callers

nothing calls this directly

Calls 11

mng_MakeLockerFunction · 0.85
FindGameFileFunction · 0.85
mng_FindTrackLockFunction · 0.85
OutrageMessageBoxFunction · 0.85
mng_CheckIfPageOwnedFunction · 0.85
mng_FreeTrackLockFunction · 0.85
mng_DeletePageFunction · 0.85
mng_DeletePagelockFunction · 0.85
FreeGamefileFunction · 0.85
mng_EraseLockerFunction · 0.85
GetTextMethod · 0.45

Tested by

no test coverage detected