Assumes ProjectFileIO::mFileName has been set to the desired path.
| 341 | |
| 342 | // Assumes ProjectFileIO::mFileName has been set to the desired path. |
| 343 | bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs) |
| 344 | { |
| 345 | // See explanation above |
| 346 | // ProjectDisabler disabler(this); |
| 347 | auto &proj = mProject; |
| 348 | auto &window = GetProjectFrame( proj ); |
| 349 | auto &projectFileIO = ProjectFileIO::Get( proj ); |
| 350 | const auto &settings = ProjectSettings::Get( proj ); |
| 351 | |
| 352 | // Some confirmation dialogs |
| 353 | { |
| 354 | if (TempDirectory::FATFilesystemDenied(fileName, XO("Projects cannot be saved to FAT drives."))) |
| 355 | { |
| 356 | return false; |
| 357 | } |
| 358 | |
| 359 | wxULongLong fileSize = wxFileName::GetSize(projectFileIO.GetFileName()); |
| 360 | |
| 361 | wxDiskspaceSize_t freeSpace; |
| 362 | if (wxGetDiskSpace(FileNames::AbbreviatePath(fileName), NULL, &freeSpace)) |
| 363 | { |
| 364 | if (freeSpace.GetValue() <= fileSize.GetValue()) |
| 365 | { |
| 366 | BasicUI::ShowErrorDialog( *ProjectFramePlacement( &proj ), |
| 367 | XO("Insufficient Disk Space"), |
| 368 | XO("The project size exceeds the available free space on the target disk.\n\n" |
| 369 | "Please select a different disk with more free space."), |
| 370 | "Error:_Disk_full_or_not_writable" |
| 371 | ); |
| 372 | |
| 373 | return false; |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | // End of confirmations |
| 378 | |
| 379 | // Always save a backup of the original project file |
| 380 | std::optional<ProjectFileIO::BackupProject> pBackupProject; |
| 381 | if (fromSaveAs && wxFileExists(fileName)) |
| 382 | { |
| 383 | pBackupProject.emplace(projectFileIO, fileName); |
| 384 | if (!pBackupProject->IsOk()) |
| 385 | return false; |
| 386 | } |
| 387 | |
| 388 | if (FileNames::IsOnFATFileSystem(fileName)) |
| 389 | { |
| 390 | if (wxFileName::GetSize(projectFileIO.GetFileName()) > UINT32_MAX) |
| 391 | { |
| 392 | BasicUI::ShowErrorDialog( *ProjectFramePlacement( &proj ), |
| 393 | XO("Error Saving Project"), |
| 394 | XO("The project exceeds the maximum size of 4GB when writing to a FAT32 formatted filesystem."), |
| 395 | "Error:_Unsuitable_drive" |
| 396 | ); |
| 397 | return false; |
| 398 | } |
| 399 | } |
| 400 |
nothing calls this directly
no test coverage detected