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

Function SaveSceneToFile

trunk/win/Source/BT_Util.cpp:2413–2471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2411}
2412
2413void SaveSceneToFile()
2414{
2415 QMutexLocker m(&GLOBAL(saveSceneMutex));
2416 if (GLOBAL(skipSavingSceneFile))
2417 return;
2418
2419 QFileInfo filePath = scnManager->getScenePbBumpFile();
2420 QFileInfo backupFilePath = scnManager->getBackupScenePbBumpFile();
2421 QString filePathStr = native(filePath);
2422 QString backupFilePathStr = native(backupFilePath);
2423 bool isLocalSceneFile = filePathStr.startsWith(native(scnManager->getWorkingDirectory()), Qt::CaseInsensitive);
2424
2425 // unhide the scene files so we can modify it
2426 if ((fsManager->getFileAttributes(filePathStr) & Hidden) > 0)
2427 fsManager->setFileAttributes(filePathStr, Normal);
2428 if ((fsManager->getFileAttributes(backupFilePathStr) & Hidden) > 0)
2429 fsManager->setFileAttributes(backupFilePathStr, Normal);
2430
2431 // don't save the backup when in shell extension mode
2432 if (!scnManager->isShellExtension)
2433 {
2434 // replace the previous backup
2435 if (exists(backupFilePath))
2436 QFile::remove(backupFilePathStr);
2437
2438 // make the current scene file the backup
2439 if (exists(filePath))
2440 QFile::rename(filePathStr, backupFilePathStr);
2441 }
2442
2443 // ensure that the scene file creation date time matches the modified time
2444 if (scnManager->getSceneBumpFile().created() < QDateTime::currentDateTime())
2445 {
2446 HANDLE hFile = CreateFile((LPCTSTR) filePathStr.utf16(),
2447 GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
2448 if (hFile)
2449 {
2450 FILETIME now;
2451 GetSystemTimeAsFileTime(&now);
2452 SetFileTime(hFile, &now, NULL, NULL);
2453 CloseHandle(hFile);
2454 }
2455 }
2456
2457 // save the scene
2458 PbPersistenceManager::getInstance()->saveScene(filePathStr);
2459
2460 // mark files hidden again
2461 // Note: only local scene files (scene files not in the user data folder) will
2462 // be hidden
2463 if (isLocalSceneFile)
2464 {
2465 if (exists(filePathStr))
2466 fsManager->setFileAttributes(filePathStr, Hidden);
2467 if (!scnManager->isShellExtension && exists(backupFilePath))
2468 fsManager->setFileAttributes(backupFilePathStr, Hidden);
2469 }
2470 m.unlock();

Callers 7

onLaunchMethod · 0.85
ExitBumptopFunction · 0.85
LoadSceneFromFileFunction · 0.85
Key_ClearBumpTopFunction · 0.85
SwitchToLibraryFunction · 0.85
messageProcMethod · 0.85

Calls 12

currentDateTimeFunction · 0.85
getWorkingDirectoryMethod · 0.80
getFileAttributesMethod · 0.80
setFileAttributesMethod · 0.80
getSceneBumpFileMethod · 0.80
saveSceneMethod · 0.80
nativeFunction · 0.70
existsFunction · 0.70
removeFunction · 0.50
renameFunction · 0.50
startsWithMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected