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

Method DoExport

src/export/ExportAudioDialog.cpp:974–1055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

972}
973
974ExportResult ExportAudioDialog::DoExport(const ExportPlugin& plugin,
975 int formatIndex,
976 const ExportProcessor::Parameters& parameters,
977 const wxFileName& filename,
978 int channels,
979 double t0, double t1, bool selectedOnly,
980 const Tags& tags,
981 FilePaths& exportedFiles)
982{
983 wxFileName name;
984
985 wxLogDebug(wxT("Doing multiple Export: File name \"%s\""), (filename.GetFullName()));
986 wxLogDebug(wxT("Channels: %i, Start: %lf, End: %lf "), channels, t0, t1);
987 if (selectedOnly)
988 wxLogDebug(wxT("Selected Region Only"));
989 else
990 wxLogDebug(wxT("Whole Project"));
991
992 wxFileName backup;
993 if (mOverwriteExisting->GetValue()) {
994 name = filename;
995 backup.Assign(name);
996
997 int suffix = 0;
998 do {
999 backup.SetName(name.GetName() +
1000 wxString::Format(wxT("%d"), suffix));
1001 ++suffix;
1002 }
1003 while (backup.FileExists());
1004 ::wxRenameFile(filename.GetFullPath(), backup.GetFullPath());
1005 }
1006 else {
1007 name = filename;
1008 int i = 2;
1009 wxString base(name.GetName());
1010 while (name.FileExists()) {
1011 name.SetName(wxString::Format(wxT("%s-%d"), base, i++));
1012 }
1013 }
1014
1015 bool success{false};
1016 const wxString fullPath{name.GetFullPath()};
1017
1018 auto cleanup = finally( [&] {
1019 if (backup.IsOk()) {
1020 if ( success )
1021 // Remove backup
1022 ::wxRemoveFile(backup.GetFullPath());
1023 else {
1024 // Restore original
1025 ::wxRemoveFile(fullPath);
1026 ::wxRenameFile(backup.GetFullPath(), fullPath);
1027 }
1028 }
1029 else {
1030 if ( ! success )
1031 // Remove any new, and only partially written, file.

Callers

nothing calls this directly

Calls 15

finallyFunction · 0.85
ExceptionWrappedCallFunction · 0.85
GetFullNameMethod · 0.80
BuildMethod · 0.80
SetFileNameMethod · 0.80
SetNumChannelsMethod · 0.80
GetValueMethod · 0.45
AssignMethod · 0.45
SetNameMethod · 0.45
GetNameMethod · 0.45
IsOkMethod · 0.45
SetRangeMethod · 0.45

Tested by

no test coverage detected