diff --git a/src/FileNames.cpp b/src/FileNames.cpp index a8673ae83..1636fc576 100644 --- a/src/FileNames.cpp +++ b/src/FileNames.cpp @@ -84,6 +84,21 @@ wxString FileNames::AutoSaveDir() return FileNames::MkDir(autoSaveDir.GetFullPath()); } +// The APP name has upercase first letter (so that Quit Audacity is correctly +// capitalised on Mac, but we want lower case APP name in paths. +// This function does that substitution, IF the last component of +// the path is 'Audacity'. +wxString FileNames::LowerCaseAppNameInPath( const wxString & dirIn){ + wxString dir = dirIn; + // BUG 1577 Capitalisation of Audacity in path... + if( dir.EndsWith( "Audacity" ) ) + { + int nChars = dir.Length() - wxString( "Audacity" ).Length(); + dir = dir.Left( nChars ) + "audacity"; + } + return dir; +} + wxString FileNames::DataDir() { // LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict @@ -112,20 +127,21 @@ wxString FileNames::DataDir() } else { // Use OS-provided user data dir folder - wxString dataDir; + wxString dataDir( LowerCaseAppNameInPath( wxStandardPaths::Get().GetUserDataDir() )); #if defined( __WXGTK__ ) - dataDir = wxStandardPaths::Get().GetUserDataDir() + wxT("-data"); -#else - dataDir = wxStandardPaths::Get().GetUserDataDir(); + dataDir = dataDir + wxT("-data"); #endif - gDataDir = FileNames::MkDir(dataDir); } } - return gDataDir; } +wxString FileNames::ResourcesDir(){ + wxString resourcesDir( LowerCaseAppNameInPath( wxStandardPaths::Get().GetResourcesDir() )); + return resourcesDir; +} + wxString FileNames::HtmlHelpDir() { #if defined(__WXMAC__) @@ -136,14 +152,13 @@ wxString FileNames::HtmlHelpDir() // just remove the MacOSX part. exePath.RemoveLastDir(); + //for mac this puts us within the .app: Audacity.app/Contents/SharedSupport/ return wxFileName( exePath.GetPath()+wxT("/help/manual"), wxEmptyString ).GetFullPath(); #else //linux goes into /*prefix*/share/audacity/ - //windows goes into the dir containing the .exe - wxString exeDir = wxStandardPaths::Get().GetDataDir(); - - //for mac this puts us within the .app: Audacity.app/Contents/SharedSupport/ - return wxFileName( exeDir+wxT("/help/manual"), wxEmptyString ).GetFullPath(); + //windows (probably) goes into the dir containing the .exe + wxString dataDir = FileNames::LowerCaseAppNameInPath( wxStandardPaths::Get().GetDataDir()); + return wxFileName( dataDir+wxT("/help/manual"), wxEmptyString ).GetFullPath(); #endif } @@ -195,7 +210,7 @@ wxString FileNames::BaseDir() baseDir = PlatformCompatibility::GetExecutablePath(); #else // Linux goes into /*prefix*/share/audacity/ - baseDir = wxStandardPaths::Get().GetDataDir(); + baseDir = FileNames::LowerCaseAppNameInPath(wxStandardPaths::Get().GetDataDir()); #endif return baseDir.GetPath(); diff --git a/src/FileNames.h b/src/FileNames.h index 7db213c0e..bff19e1e8 100644 --- a/src/FileNames.h +++ b/src/FileNames.h @@ -28,12 +28,14 @@ public: // originally an ExportMultiple method. Append suffix if newName appears in otherNames. static void MakeNameUnique(wxArrayString &otherNames, wxFileName &newName); + static wxString LowerCaseAppNameInPath( const wxString & dirIn); /** \brief Audacity user data directory * * Where audacity keeps it's settings and other user data squirreled away, * by default ~/.audacity-data/ on Unix, Application Data/Audacity on * windows system */ static wxString DataDir(); + static wxString ResourcesDir(); static wxString AutoSaveDir(); static wxString HtmlHelpDir(); static wxString HtmlHelpIndexFile(bool quick); diff --git a/src/Prefs.cpp b/src/Prefs.cpp index 9c5bc269c..677f18154 100755 --- a/src/Prefs.cpp +++ b/src/Prefs.cpp @@ -149,7 +149,9 @@ void InitPreferences() wxString langCode = gPrefs->Read(wxT("/Locale/Language"), wxEmptyString); bool writeLang = false; - const wxFileName fn(wxStandardPaths::Get().GetResourcesDir(), wxT("FirstTime.ini")); + const wxFileName fn( + FileNames::ResourcesDir(), + wxT("FirstTime.ini")); if (fn.FileExists()) // it will exist if the (win) installer put it there { const wxString fullPath{fn.GetFullPath()}; diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index eb98dfd85..a3252ade7 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -1466,9 +1466,8 @@ void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) EQCurveArray userCurves = mCurves; mCurves.Clear(); // We only wamt to look for the shipped EQDefaultCurves.xml - wxFileName fn = wxFileName(wxStandardPaths::Get().GetResourcesDir(), - wxT("EQDefaultCurves.xml")); - wxLogDebug(wxT("Attempting to load EQDefaultCurves.xml from %s"),wxStandardPaths::Get().GetResourcesDir().c_str()); + wxFileName fn = wxFileName(FileNames::ResourcesDir(), wxT("EQDefaultCurves.xml")); + wxLogDebug(wxT("Attempting to load EQDefaultCurves.xml from %s"),fn.GetFullPath().c_str()); XMLFileReader reader; if(!reader.Parse(this, fn.GetFullPath())) { @@ -1577,9 +1576,7 @@ bool EffectEqualization::GetDefaultFileName(wxFileName &fileName) if( !fileName.FileExists() ) { // Default file not found in the data dir. Fall back to Resources dir. // See http://docs.wxwidgets.org/trunk/classwx_standard_paths.html#5514bf6288ee9f5a0acaf065762ad95d - static wxString resourcesDir; - resourcesDir = wxStandardPaths::Get().GetResourcesDir(); - fileName = wxFileName( resourcesDir, wxT("EQDefaultCurves.xml") ); + fileName = wxFileName( FileNames::ResourcesDir(), wxT("EQDefaultCurves.xml") ); } if( !fileName.FileExists() ) {