This version of SaveAs is invoked only from scripting and does not prompt for a file name
| 441 | // This version of SaveAs is invoked only from scripting and does not |
| 442 | // prompt for a file name |
| 443 | bool ProjectFileManager::SaveAs(const FilePath &newFileName, bool addToHistory /*= true*/) |
| 444 | { |
| 445 | auto &project = mProject; |
| 446 | auto &projectFileIO = ProjectFileIO::Get( project ); |
| 447 | |
| 448 | auto oldFileName = projectFileIO.GetFileName(); |
| 449 | |
| 450 | bool bOwnsNewName = !projectFileIO.IsTemporary() && (oldFileName == newFileName); |
| 451 | //check to see if the NEW project file already exists. |
| 452 | //We should only overwrite it if this project already has the same name, where the user |
| 453 | //simply chose to use the save as command although the save command would have the effect. |
| 454 | if( !bOwnsNewName && wxFileExists(newFileName)) { |
| 455 | AudacityMessageDialog m( |
| 456 | nullptr, |
| 457 | XO("The project was not saved because the file name provided would overwrite another project.\nPlease try again and select an original name."), |
| 458 | XO("Error Saving Project"), |
| 459 | wxOK|wxICON_ERROR ); |
| 460 | m.ShowModal(); |
| 461 | return false; |
| 462 | } |
| 463 | |
| 464 | auto success = DoSave(newFileName, !bOwnsNewName); |
| 465 | if (success && addToHistory) { |
| 466 | FileHistory::Global().Append( projectFileIO.GetFileName() ); |
| 467 | } |
| 468 | |
| 469 | return(success); |
| 470 | } |
| 471 | |
| 472 | bool ProjectFileManager::SaveAs(bool allowOverwrite /* = false */) |
| 473 | { |
no test coverage detected