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

Method Build

libraries/lib-import-export/Export.cpp:84–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84ExportTask ExportTaskBuilder::Build(AudacityProject& project)
85{
86 //File rename stuff should be moved out to somewhere else...
87 auto filename = mFileName;
88
89 //For safety, if the file already exists we use temporary filename
90 //and replace original one export succeeded
91 int suffix = 0;
92 while (filename.FileExists()) {
93 filename.SetName(mFileName.GetName() +
94 wxString::Format(wxT("%d"), suffix));
95 suffix++;
96 }
97
98 auto processor = mPlugin->CreateProcessor(mFormat);
99 if(!processor->Initialize(project,
100 mParameters,
101 mFileName.GetFullPath(),
102 mT0, mT1, mSelectedOnly,
103 mSampleRate, mMixerSpec ? mMixerSpec->GetNumChannels() : mNumChannels,
104 mMixerSpec,
105 mTags))
106 {
107 return ExportTask([](ExportProcessorDelegate&){ return ExportResult::Cancelled; });
108 }
109
110 return ExportTask([actualFilename = filename,
111 targetFilename = mFileName,
112 processor = std::shared_ptr<ExportProcessor>(processor.release())]
113 (ExportProcessorDelegate& delegate)
114 {
115 auto result = ExportResult::Error;
116 auto cleanup = finally( [&] {
117 if(result == ExportResult::Success || result == ExportResult::Stopped)
118 {
119 if (actualFilename != targetFilename)
120 {
121 //may fail...
122 ::wxRenameFile(actualFilename.GetFullPath(),
123 targetFilename.GetFullPath(),
124 true);
125 }
126 }
127 else
128 ::wxRemoveFile(actualFilename.GetFullPath());
129 } );
130 result = processor->Process(delegate);
131 return result;
132 });
133}
134
135void ShowDiskFullExportErrorDialog(const wxFileNameWrapper &fileName)
136{

Callers 7

ExportProjectMethod · 0.80
ExportProjectMethod · 0.80
ApplyMethod · 0.80
OnExportMethod · 0.80
DoExportMethod · 0.80
DoExportFunction · 0.80

Calls 7

finallyFunction · 0.85
SetNameMethod · 0.45
GetNameMethod · 0.45
CreateProcessorMethod · 0.45
InitializeMethod · 0.45
releaseMethod · 0.45
ProcessMethod · 0.45

Tested by

no test coverage detected