Audacity 3.2.0
Functions
Legacy.h File Reference
#include <wx/defs.h>
Include dependency graph for Legacy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool ConvertLegacyProjectFile (const wxFileName &filename)
 Update Audacity 1.0 file in-place to XML format. More...
 

Function Documentation

◆ ConvertLegacyProjectFile()

bool ConvertLegacyProjectFile ( const wxFileName &  filename)

Update Audacity 1.0 file in-place to XML format.

Returns
true if successful, else no effect on the file
Exception safety guarantee:
Strong

Definition at line 249 of file Legacy.cpp.

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
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;
307 } );
308}
wxT("CloseDown"))
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
XO("Cut/Copy/Paste")
static bool ConvertLegacyTrack(wxTextFile *f, XMLFileWriter &xmlFile)
Definition: Legacy.cpp:43
wxString name
Definition: TagsEditor.cpp:166
TranslatableString label
Definition: TagsEditor.cpp:165
Abstract base class used in importing a file.
Wrapper to output XML data to files.
Definition: XMLWriter.h:84

References AudacityMessageBox(), ConvertLegacyTrack(), label, name, wxT(), and XO().

Here is the call graph for this function: