1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 16:48:44 +02:00

(bug 20, P2)

Fix auto-recovery failures that Gale reported, when auto-recovered projects had been saved to top-level directories, e.g., "E:\dtmf.aup" on Windows. Problem was with file separators. This DirManager code is quite convoluted, touched by multiple chefs, and called from many places, so this fix does not correct the origination(s) of the problem, but doesn't break anything higher up, and is a failsafe against probably multiple errors at higher levels.

Make some parameter names clearer vs class vars. Readability is better if the names are not lexicographically exactly the same.
This commit is contained in:
v.audacity 2010-09-28 05:03:50 +00:00
parent bd39b07260
commit 8f20e65167
2 changed files with 11 additions and 9 deletions

View File

@ -381,8 +381,7 @@ void DirManager::CleanTempDir()
RecursivelyRemove(filePathArray, count, true, true, _("Cleaning up temporary files")); RecursivelyRemove(filePathArray, count, true, true, _("Cleaning up temporary files"));
} }
bool DirManager::SetProject(wxString & projPath, wxString & projName, bool DirManager::SetProject(wxString& newProjPath, wxString& newProjName, const bool bCreate)
bool create)
{ {
wxString oldPath = this->projPath; wxString oldPath = this->projPath;
wxString oldName = this->projName; wxString oldName = this->projName;
@ -391,17 +390,20 @@ bool DirManager::SetProject(wxString & projPath, wxString & projName,
if (oldLoc == wxT("")) if (oldLoc == wxT(""))
oldLoc = mytemp; oldLoc = mytemp;
if (projPath == wxT("")) if (newProjPath == wxT(""))
projPath = ::wxGetCwd(); newProjPath = ::wxGetCwd();
this->projPath = projPath; this->projPath = newProjPath;
this->projName = projName; this->projName = newProjName;
this->projFull = projPath + wxFILE_SEP_PATH + projName; if (newProjPath.Last() == wxFILE_SEP_PATH)
this->projFull = newProjPath + newProjName;
else
this->projFull = newProjPath + wxFILE_SEP_PATH + newProjName;
wxString cleanupLoc1=oldLoc; wxString cleanupLoc1=oldLoc;
wxString cleanupLoc2=projFull; wxString cleanupLoc2=projFull;
if (create) { if (bCreate) {
if (!wxDirExists(projFull)) if (!wxDirExists(projFull))
if (!wxMkdir(projFull)) if (!wxMkdir(projFull))
return false; return false;

View File

@ -49,7 +49,7 @@ class DirManager: public XMLTagHandler {
// Returns true on success. // Returns true on success.
// If SetProject is told NOT to create the directory // If SetProject is told NOT to create the directory
// but it doesn't already exist, SetProject fails and returns false. // but it doesn't already exist, SetProject fails and returns false.
bool SetProject(wxString & projPath, wxString & projName, bool create); bool SetProject(wxString& newProjPath, wxString& newProjName, const bool bCreate);
wxString GetProjectDataDir(); wxString GetProjectDataDir();
wxString GetProjectName(); wxString GetProjectName();