MCPcopy Create free account
hub / github.com/audacity/audacity / SaveCopy

Method SaveCopy

src/ProjectFileManager.cpp:611–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

609}
610
611bool ProjectFileManager::SaveCopy(const FilePath &fileName /* = wxT("") */)
612{
613 auto &project = mProject;
614 auto &projectFileIO = ProjectFileIO::Get(project);
615 auto &window = GetProjectFrame(project);
616 TitleRestorer Restorer(window, project); // RAII
617 wxFileName filename = fileName;
618 FilePath defaultSavePath = FileNames::FindDefaultPath(FileNames::Operation::Save);
619
620 if (fileName.empty())
621 {
622 if (projectFileIO.IsTemporary())
623 {
624 filename.SetPath(defaultSavePath);
625 }
626 else
627 {
628 filename = projectFileIO.GetFileName();
629 }
630 }
631
632 // Bug 1304: Set a default file path if none was given. For Save/SaveAs/SaveCopy
633 if (!FileNames::IsPathAvailable(filename.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR)))
634 {
635 filename.SetPath(defaultSavePath);
636 }
637
638 TranslatableString title =
639 XO("%sSave Copy of Project \"%s\" As...")
640 .Format(Restorer.sProjNumber, Restorer.sProjName);
641
642 bool bPrompt = (project.mBatchMode == 0) || (projectFileIO.GetFileName().empty());
643 FilePath fName;
644
645 do
646 {
647 if (bPrompt)
648 {
649 // JKC: I removed 'wxFD_OVERWRITE_PROMPT' because we are checking
650 // for overwrite ourselves later, and we disallow it.
651 // Previously we disallowed overwrite because we would have had
652 // to DELETE the many smaller files too, or prompt to move them.
653 // Maybe we could allow it now that we have aup3 format?
654 fName = SelectFile(FileNames::Operation::Export,
655 title,
656 filename.GetPath(),
657 filename.GetFullName(),
658 wxT("aup3"),
659 { FileNames::AudacityProjects },
660 wxFD_SAVE | wxRESIZE_BORDER,
661 &window);
662
663 if (fName.empty())
664 {
665 return false;
666 }
667
668 filename = fName;

Callers 2

ApplyMethod · 0.45
OnSaveCopyFunction · 0.45

Calls 11

GetFunction · 0.85
SelectFileFunction · 0.85
ShowErrorDialogFunction · 0.85
ProjectFramePlacementFunction · 0.85
IsTemporaryMethod · 0.80
GetFullNameMethod · 0.80
emptyMethod · 0.45
SetPathMethod · 0.45
GetPathMethod · 0.45
ShowModalMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected