Audacity  2.2.2
Functions
Legacy.h File Reference
#include <wx/defs.h>
#include <wx/filename.h>

Go to the source code of this file.

Functions

bool ConvertLegacyProjectFile (const wxFileName &filename)
 

Function Documentation

bool ConvertLegacyProjectFile ( const wxFileName &  filename)

Definition at line 253 of file Legacy.cpp.

References _(), AUDACITY_VERSION_STRING, AudacityMessageBox(), ConvertLegacyTrack(), label, and name.

Referenced by AudacityProject::OpenFile().

254 {
255  wxTextFile f;
256 
257  const wxString name = filename.GetFullPath();
258  f.Open( name );
259  if (!f.IsOpened())
260  return false;
261 
262  return GuardedCall< bool >( [&] {
263  XMLFileWriter xmlFile{ name, _("Error Converting Legacy Project File") };
264 
265  xmlFile.Write(wxT("<?xml version=\"1.0\"?>\n"));
266 
267  wxString label;
268  wxString value;
269 
270  if (f.GetFirstLine() != wxT("AudacityProject"))
271  return false;
272  if (f.GetNextLine() != wxT("Version"))
273  return false;
274  if (f.GetNextLine() != wxT("0.95"))
275  return false;
276  if (f.GetNextLine() != wxT("projName"))
277  return false;
278 
279  xmlFile.StartTag(wxT("audacityproject"));
280  xmlFile.WriteAttr(wxT("projname"), f.GetNextLine());
281  xmlFile.WriteAttr(wxT("version"), wxT("1.1.0"));
282  xmlFile.WriteAttr(wxT("audacityversion"),AUDACITY_VERSION_STRING);
283 
284  label = f.GetNextLine();
285  while (label != wxT("BeginTracks")) {
286  xmlFile.WriteAttr(label, f.GetNextLine());
287  label = f.GetNextLine();
288  }
289 
290  label = f.GetNextLine();
291  while (label != wxT("EndTracks")) {
292  bool success = ConvertLegacyTrack(&f, xmlFile);
293  if (!success)
294  return false;
295  label = f.GetNextLine();
296  }
297 
298  // Close original before Commit() tries to overwrite it.
299  f.Close();
300 
301  xmlFile.EndTag(wxT("audacityproject"));
302  xmlFile.Commit();
303 
304  ::AudacityMessageBox(wxString::Format(_("Converted a 1.0 project file to the new format.\nThe old file has been saved as '%s'"), xmlFile.GetBackupName()),
305  _("Opening Audacity Project"));
306 
307  return true;
308  } );
309 }
#define AUDACITY_VERSION_STRING
Definition: Audacity.h:81
wxString label
Definition: Tags.cpp:727
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
Wrapper to output XML data to files.
Definition: XMLWriter.h:74
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
const wxChar * name
Definition: Distortion.cpp:94
static bool ConvertLegacyTrack(wxTextFile *f, XMLFileWriter &xmlFile)
Definition: Legacy.cpp:47