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

Function SwitcherooFiles

manage/manage.cpp:1464–1495  ·  view source on GitHub ↗

Removes a file, then renames another file to be the removed file. Get it? Returns 1 on success, else 0 on fail

Source from the content-addressed store, hash-verified

1462// Removes a file, then renames another file to be the removed file. Get it?
1463// Returns 1 on success, else 0 on fail
1464int SwitcherooFiles(const char *name, char *tempname) {
1465 /*// If we're changing the net table file, make a backup first!
1466 if ((!stricmp (name,TableFilename)))
1467 {
1468 cf_CopyFile (BackupTableFilename,TableFilename);
1469 cf_CopyFile (BackupLockFilename,TableLockFilename);
1470 }*/
1471 int num_tries = 0;
1472 while (!ddio_DeleteFile(name) && num_tries < MAX_TRIES) {
1473 Sleep(100);
1474 num_tries++;
1475 }
1476 if (num_tries >= MAX_TRIES) {
1477 strcpy(ErrorString, "MANAGE:There was a problem deleting the table file.");
1478 ASSERT(0); // GET JASON IMMEDIATELY
1479 Int3();
1480 return (0);
1481 }
1482 num_tries = 0;
1483 while ((rename(tempname, name)) && num_tries <= MAX_TRIES) {
1484 Sleep(100);
1485 num_tries++;
1486 }
1487 if (num_tries >= MAX_TRIES) {
1488 strcpy(ErrorString, "MANAGE:There was a problem renaming the temp file.");
1489 ASSERT(0); // Get JASON IMMEDIATELY
1490 Int3();
1491 return (0);
1492 }
1493
1494 return 1;
1495}
1496
1497void mng_TransferPages() {
1498 CFILE *infile, *outfile;

Callers 6

mng_ReplacePagelockFunction · 0.85
ReorderPagesFunction · 0.85
mng_ReplacePageFunction · 0.85
mng_DeletePageFunction · 0.85
mng_DeleteTexPageSeriesFunction · 0.85
SaveTableMethod · 0.85

Calls 2

ddio_DeleteFileFunction · 0.50
SleepFunction · 0.50

Tested by

no test coverage detected