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

Function ConvertLegacyProjectFile

src/Legacy.cpp:249–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249bool ConvertLegacyProjectFile(const wxFileName &filename)
250{
251 wxTextFile f;
252
253 const wxString name = filename.GetFullPath();
254 f.Open( name );
255 if (!f.IsOpened())
256 return false;
257
258 return GuardedCall< bool >( [&] {
259 XMLFileWriter xmlFile{ name, XO("Error Converting Legacy Project File") };
260
261 xmlFile.Write(wxT("<?xml version=\"1.0\"?>\n"));
262
263 wxString label;
264 wxString value;
265
266 if (f.GetFirstLine() != wxT("AudacityProject"))
267 return false;
268 if (f.GetNextLine() != wxT("Version"))
269 return false;
270 if (f.GetNextLine() != wxT("0.95"))
271 return false;
272 if (f.GetNextLine() != wxT("projName"))
273 return false;
274
275 xmlFile.StartTag(wxT("audacityproject"));
276 xmlFile.WriteAttr(wxT("projname"), f.GetNextLine());
277 xmlFile.WriteAttr(wxT("version"), wxT("1.1.0"));
278 xmlFile.WriteAttr(wxT("audacityversion"),AUDACITY_VERSION_STRING);
279
280 label = f.GetNextLine();
281 while (label != wxT("BeginTracks")) {
282 xmlFile.WriteAttr(label, f.GetNextLine());
283 label = f.GetNextLine();
284 }
285
286 label = f.GetNextLine();
287 while (label != wxT("EndTracks")) {
288 bool success = ConvertLegacyTrack(&f, xmlFile);
289 if (!success)
290 return false;
291 label = f.GetNextLine();
292 }
293
294 // Close original before Commit() tries to overwrite it.
295 f.Close();
296
297 xmlFile.EndTag(wxT("audacityproject"));
298 xmlFile.Commit();
299
300 ::AudacityMessageBox(
301 XO(
302"Converted a 1.0 project file to the new format.\nThe old file has been saved as '%s'")
303 .Format( xmlFile.GetBackupName() ),
304 XO("Opening Audacity Project"));
305
306 return true;

Callers

nothing calls this directly

Calls 10

ConvertLegacyTrackFunction · 0.85
AudacityMessageBoxFunction · 0.85
IsOpenedMethod · 0.80
OpenMethod · 0.45
WriteMethod · 0.45
StartTagMethod · 0.45
WriteAttrMethod · 0.45
CloseMethod · 0.45
EndTagMethod · 0.45
CommitMethod · 0.45

Tested by

no test coverage detected