From a30000cf74e071716ea5befd4b7ff3acffccfb80 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 7 Mar 2019 14:50:22 -0500 Subject: [PATCH] Use type aliases FilePath, FilePaths... ... for wxString and wxArrayStringEx, holding file paths (absolute or relative, directory or plain file); to be replaced later with different types (not yet using std::vector, becase of some uses of wxArrayString::Index with two arguments) --- include/audacity/EffectInterface.h | 4 +- include/audacity/ModuleInterface.h | 2 +- include/audacity/PluginInterface.h | 4 +- include/audacity/Types.h | 3 + src/AudacityApp.cpp | 18 ++-- src/AudacityApp.h | 17 ++-- src/AutoRecovery.cpp | 6 +- src/AutoRecovery.h | 2 +- src/BatchCommands.cpp | 6 +- src/BatchCommands.h | 2 +- src/DirManager.cpp | 102 ++++++++++----------- src/DirManager.h | 36 ++++---- src/FFmpeg.cpp | 4 +- src/FFmpeg.h | 4 +- src/FileNames.cpp | 59 ++++++------ src/FileNames.h | 63 +++++++------ src/Languages.cpp | 6 +- src/Menus.h | 3 +- src/ModuleManager.cpp | 14 +-- src/ModuleManager.h | 4 +- src/PlatformCompatibility.cpp | 8 +- src/PlatformCompatibility.h | 7 +- src/PluginManager.cpp | 10 +- src/PluginManager.h | 4 +- src/Project.cpp | 33 ++++--- src/Project.h | 18 ++-- src/Sequence.cpp | 4 +- src/Sequence.h | 4 +- src/Theme.cpp | 14 +-- src/TimerRecordDialog.cpp | 4 +- src/WaveClip.cpp | 4 +- src/WaveClip.h | 4 +- src/WaveTrack.cpp | 4 +- src/WaveTrack.h | 4 +- src/blockfile/LegacyAliasBlockFile.cpp | 2 +- src/blockfile/LegacyAliasBlockFile.h | 2 +- src/blockfile/LegacyBlockFile.cpp | 2 +- src/blockfile/LegacyBlockFile.h | 2 +- src/commands/LoadCommands.h | 2 +- src/commands/OpenSaveCommands.cpp | 4 +- src/effects/LoadEffects.h | 2 +- src/effects/VST/VSTEffect.cpp | 8 +- src/effects/VST/VSTEffect.h | 2 +- src/effects/audiounits/AudioUnitEffect.cpp | 2 +- src/effects/audiounits/AudioUnitEffect.h | 2 +- src/effects/ladspa/LadspaEffect.cpp | 14 +-- src/effects/ladspa/LadspaEffect.h | 4 +- src/effects/lv2/LoadLV2.h | 2 +- src/effects/nyquist/LoadNyquist.cpp | 10 +- src/effects/nyquist/LoadNyquist.h | 2 +- src/effects/nyquist/Nyquist.cpp | 8 +- src/effects/nyquist/Nyquist.h | 2 +- src/effects/vamp/LoadVamp.cpp | 5 + src/effects/vamp/LoadVamp.h | 4 +- src/export/Export.cpp | 2 +- src/export/ExportMultiple.cpp | 4 +- src/export/ExportMultiple.h | 2 +- src/import/Import.cpp | 4 +- src/import/Import.h | 4 +- src/import/ImportFFmpeg.cpp | 10 +- src/import/ImportFLAC.cpp | 8 +- src/import/ImportLOF.cpp | 8 +- src/import/ImportMIDI.cpp | 2 +- src/import/ImportMIDI.h | 3 +- src/import/ImportMP3.cpp | 6 +- src/import/ImportOGG.cpp | 6 +- src/import/ImportPCM.cpp | 8 +- src/import/ImportPlugin.h | 6 +- src/menus/FileMenus.cpp | 2 +- src/prefs/ModulePrefs.cpp | 4 +- src/prefs/ModulePrefs.h | 6 +- src/widgets/FileHistory.cpp | 6 +- src/widgets/FileHistory.h | 9 +- src/widgets/wxPanelWrapper.h | 10 +- src/xml/XMLFileReader.cpp | 2 +- src/xml/XMLFileReader.h | 3 +- src/xml/XMLTagHandler.cpp | 10 +- src/xml/XMLTagHandler.h | 12 ++- src/xml/XMLWriter.cpp | 4 +- src/xml/XMLWriter.h | 10 +- 80 files changed, 371 insertions(+), 342 deletions(-) diff --git a/include/audacity/EffectInterface.h b/include/audacity/EffectInterface.h index aad0387f0..4a681a7af 100755 --- a/include/audacity/EffectInterface.h +++ b/include/audacity/EffectInterface.h @@ -253,8 +253,8 @@ public: virtual ~EffectManagerInterface() {}; virtual void FindFilesInPathList(const wxString & pattern, - const wxArrayString & pathList, - wxArrayString & files, + const FilePaths & pathList, + FilePaths & files, int searchFlags) = 0; }; diff --git a/include/audacity/ModuleInterface.h b/include/audacity/ModuleInterface.h index 67d389ca1..1bdecec42 100644 --- a/include/audacity/ModuleInterface.h +++ b/include/audacity/ModuleInterface.h @@ -89,7 +89,7 @@ public: // Returns empty, or else, where to copy a plug-in file or bundle. // Drag-and-drop is supported only if GetFileExtensions() returns nonempty and // this function returns nonempty. - virtual wxString InstallPath() = 0; + virtual FilePath InstallPath() = 0; // Modules providing a single or static set of plugins may use // AutoRegisterPlugins() to register those plugins. diff --git a/include/audacity/PluginInterface.h b/include/audacity/PluginInterface.h index dbe784f74..a7f3b041e 100644 --- a/include/audacity/PluginInterface.h +++ b/include/audacity/PluginInterface.h @@ -68,8 +68,8 @@ public: virtual const PluginID & RegisterPlugin(ModuleInterface *provider, ImporterInterface *importer) = 0; virtual void FindFilesInPathList(const wxString & pattern, - const wxArrayString & pathList, - wxArrayString & files, + const FilePaths & pathList, + FilePaths & files, bool directories = false) = 0; virtual bool GetSharedConfigSubgroups(const PluginID & ID, const RegistryPath & group, RegistryPaths & subgroups) = 0; diff --git a/include/audacity/Types.h b/include/audacity/Types.h index 6802036c3..e21056060 100644 --- a/include/audacity/Types.h +++ b/include/audacity/Types.h @@ -73,6 +73,9 @@ class wxArrayStringEx; using FileExtension = wxString; using FileExtensions = wxArrayStringEx; +using FilePath = wxString; +using FilePaths = wxArrayStringEx; + // ---------------------------------------------------------------------------- // A native 64-bit integer...used when referring to any number of samples // ---------------------------------------------------------------------------- diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 18e5c0e4d..29a0e8037 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -765,7 +765,7 @@ END_EVENT_TABLE() // TODO: Would be nice to make this handle not opening a file with more panache. // - Inform the user if DefaultOpenPath not set. // - Switch focus to correct instance of project window, if already open. -bool AudacityApp::MRUOpen(const wxString &fullPathStr) { +bool AudacityApp::MRUOpen(const FilePath &fullPathStr) { // Most of the checks below are copied from AudacityProject::OpenFiles. // - some rationalisation might be possible. @@ -827,7 +827,7 @@ void AudacityApp::OnMRUClear(wxCommandEvent& WXUNUSED(event)) // Better, for example, to check the file type early on. void AudacityApp::OnMRUFile(wxCommandEvent& event) { int n = event.GetId() - ID_RECENT_FIRST; - const wxString &fullPathStr = mRecentFiles->GetHistoryFile(n); + const auto &fullPathStr = mRecentFiles->GetHistoryFile(n); // Try to open only if not already open. // Test IsAlreadyOpen() here even though AudacityProject::MRUOpen() also now checks, @@ -1871,7 +1871,7 @@ bool AudacityApp::CreateSingleInstanceChecker(const wxString &dir) // Windows and Linux require absolute file names as command may // not come from current working directory. - wxArrayString filenames; + FilePaths filenames; for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++) { wxFileName filename(parser->GetParam(i)); @@ -2075,8 +2075,8 @@ std::unique_ptr AudacityApp::ParseCommandLine() } // static -void AudacityApp::AddUniquePathToPathList(const wxString &pathArg, - wxArrayString &pathList) +void AudacityApp::AddUniquePathToPathList(const FilePath &pathArg, + FilePaths &pathList) { wxFileName pathNorm = pathArg; pathNorm.Normalize(); @@ -2092,7 +2092,7 @@ void AudacityApp::AddUniquePathToPathList(const wxString &pathArg, // static void AudacityApp::AddMultiPathsToPathList(const wxString &multiPathStringArg, - wxArrayString &pathList) + FilePaths &pathList) { wxString multiPathString(multiPathStringArg); while (!multiPathString.empty()) { @@ -2104,8 +2104,8 @@ void AudacityApp::AddMultiPathsToPathList(const wxString &multiPathStringArg, // static void AudacityApp::FindFilesInPathList(const wxString & pattern, - const wxArrayString & pathList, - wxArrayString & results, + const FilePaths & pathList, + FilePaths & results, int flags) { wxLogNull nolog; @@ -2158,7 +2158,7 @@ void AudacityApp::OnEndSession(wxCloseEvent & event) } } -void AudacityApp::AddFileToHistory(const wxString & name) +void AudacityApp::AddFileToHistory(const FilePath & name) { mRecentFiles->AddFileToHistory(name); } diff --git a/src/AudacityApp.h b/src/AudacityApp.h index 8f651304e..63a87c8f7 100644 --- a/src/AudacityApp.h +++ b/src/AudacityApp.h @@ -15,6 +15,7 @@ #define __AUDACITY_APP__ #include "Audacity.h" +#include "audacity/Types.h" #include "MemoryX.h" #include @@ -91,7 +92,7 @@ class AudacityApp final : public wxApp { void OnMRUClear(wxCommandEvent &event); void OnMRUFile(wxCommandEvent &event); // Backend for above - returns true for success, false for failure - bool MRUOpen(const wxString &fileName); + bool MRUOpen(const FilePath &fileName); // A wrapper of the above that does not throw bool SafeMRUOpen(const wxString &fileName); @@ -140,24 +141,24 @@ class AudacityApp final : public wxApp { * directories can be specified using the AUDACITY_PATH environment * variable. On Windows or Mac OS, this will include the directory * which contains the Audacity program. */ - wxArrayString audacityPathList; + FilePaths audacityPathList; /** \brief Default temp directory */ wxString defaultTempDir; // Useful functions for working with search paths - static void AddUniquePathToPathList(const wxString &path, - wxArrayString &pathList); + static void AddUniquePathToPathList(const FilePath &path, + FilePaths &pathList); static void AddMultiPathsToPathList(const wxString &multiPathString, - wxArrayString &pathList); + FilePaths &pathList); static void FindFilesInPathList(const wxString & pattern, - const wxArrayString & pathList, - wxArrayString &results, + const FilePaths & pathList, + FilePaths &results, int flags = wxDIR_FILES); static bool IsTempDirectoryNameOK( const wxString & Name ); FileHistory *GetRecentFiles() {return mRecentFiles.get();} - void AddFileToHistory(const wxString & name); + void AddFileToHistory(const FilePath & name); bool GetWindowRectAlreadySaved()const {return mWindowRectAlreadySaved;} void SetWindowRectAlreadySaved(bool alreadySaved) {mWindowRectAlreadySaved = alreadySaved;} diff --git a/src/AutoRecovery.cpp b/src/AutoRecovery.cpp index 692dd8b4d..fe66f531a 100644 --- a/src/AutoRecovery.cpp +++ b/src/AutoRecovery.cpp @@ -173,7 +173,7 @@ static bool HaveFilesToRecover() static bool RemoveAllAutoSaveFiles() { - wxArrayString files; + FilePaths files; wxDir::GetAllFiles(FileNames::AutoSaveDir(), &files, wxT("*.autosave"), wxDIR_FILES); @@ -205,7 +205,7 @@ static bool RecoverAllProjects(AudacityProject** pproj) // Open a project window for each auto save file wxString filename; - wxArrayString files; + FilePaths files; wxDir::GetAllFiles(FileNames::AutoSaveDir(), &files, wxT("*.autosave"), wxDIR_FILES); @@ -678,7 +678,7 @@ bool AutoSaveFile::IsEmpty() const return mBuffer.GetLength() == 0; } -bool AutoSaveFile::Decode(const wxString & fileName) +bool AutoSaveFile::Decode(const FilePath & fileName) { char ident[sizeof(AutoSaveIdent)]; size_t len = strlen(AutoSaveIdent); diff --git a/src/AutoRecovery.h b/src/AutoRecovery.h index bffd9a9f6..b1210a53a 100644 --- a/src/AutoRecovery.h +++ b/src/AutoRecovery.h @@ -105,7 +105,7 @@ public: bool IsEmpty() const; - bool Decode(const wxString & fileName); + bool Decode(const FilePath & fileName); private: void WriteName(const wxString & name); diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index fe97aa8ea..4808792f4 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -504,7 +504,7 @@ bool MacroCommands::IsMono() return ( tracks->Any() - &Track::IsLeader ).empty(); } -wxString MacroCommands::BuildCleanFileName(const wxString &fileName, +wxString MacroCommands::BuildCleanFileName(const FilePath &fileName, const FileExtension &extension) { const wxFileName newFileName{ fileName }; @@ -964,7 +964,7 @@ void MacroCommands::MigrateLegacyChains() // which old Audacity will not read. const auto oldDir = FileNames::LegacyChainDir(); - wxArrayString files; + FilePaths files; wxDir::GetAllFiles(oldDir, &files, wxT("*.txt"), wxDIR_FILES); // add a dummy path component to be overwritten by SetFullName @@ -987,7 +987,7 @@ wxArrayString MacroCommands::GetNames() MigrateLegacyChains(); wxArrayString names; - wxArrayString files; + FilePaths files; wxDir::GetAllFiles(FileNames::MacroDir(), &files, wxT("*.txt"), wxDIR_FILES); size_t i; diff --git a/src/BatchCommands.h b/src/BatchCommands.h index 4e32f2a7f..7d48e235a 100644 --- a/src/BatchCommands.h +++ b/src/BatchCommands.h @@ -74,7 +74,7 @@ class MacroCommands final { void AbortBatch(); // Utility functions for the special commands. - static wxString BuildCleanFileName(const wxString &fileName, + static wxString BuildCleanFileName(const FilePath &fileName, const FileExtension &extension); bool WriteMp3File( const wxString & Name, int bitrate ); double GetEndTime(); diff --git a/src/DirManager.cpp b/src/DirManager.cpp index 54a1fe829..6d5c5b724 100644 --- a/src/DirManager.cpp +++ b/src/DirManager.cpp @@ -159,8 +159,8 @@ wxMemorySize GetFreeMemory() // JKC: Using flag wxDIR_NO_FOLLOW to NOT follow symbolic links. // Directories and files inside a project should never be symbolic // links, so if we find one, do not follow it. -static int RecursivelyEnumerate(wxString dirPath, - wxArrayString& filePathArray, // output: all files in dirPath tree +static int RecursivelyEnumerate(const FilePath &dirPath, + FilePaths& filePathArray, // output: all files in dirPath tree wxString dirspec, wxString filespec, bool bFiles, bool bDirs, @@ -180,7 +180,7 @@ static int RecursivelyEnumerate(wxString dirPath, if (bFiles && dirspec.empty() ){ cont= dir.GetFirst(&name, filespec, wxDIR_FILES | wxDIR_HIDDEN | wxDIR_NO_FOLLOW); while ( cont ){ - wxString filepath = dirPath + wxFILE_SEP_PATH + name; + FilePath filepath = dirPath + wxFILE_SEP_PATH + name; count++; filePathArray.push_back(filepath); @@ -195,7 +195,7 @@ static int RecursivelyEnumerate(wxString dirPath, cont= dir.GetFirst(&name, dirspec, wxDIR_DIRS | wxDIR_NO_FOLLOW); while ( cont ){ - wxString subdirPath = dirPath + wxFILE_SEP_PATH + name; + FilePath subdirPath = dirPath + wxFILE_SEP_PATH + name; count += RecursivelyEnumerate( subdirPath, filePathArray, wxEmptyString,filespec, bFiles, bDirs, @@ -213,8 +213,8 @@ static int RecursivelyEnumerate(wxString dirPath, return count; } -static int RecursivelyEnumerateWithProgress(wxString dirPath, - wxArrayString& filePathArray, // output: all files in dirPath tree +static int RecursivelyEnumerateWithProgress(const FilePath &dirPath, + FilePaths& filePathArray, // output: all files in dirPath tree wxString dirspec, wxString filespec, bool bFiles, bool bDirs, @@ -235,7 +235,7 @@ static int RecursivelyEnumerateWithProgress(wxString dirPath, return count; } -static int RecursivelyCountSubdirs(wxString dirPath) +static int RecursivelyCountSubdirs( const FilePath &dirPath ) { bool bContinue; int nCount = 0; @@ -247,7 +247,7 @@ static int RecursivelyCountSubdirs(wxString dirPath) while (bContinue) { nCount++; - wxString subdirPath = dirPath + wxFILE_SEP_PATH + name; + FilePath subdirPath = dirPath + wxFILE_SEP_PATH + name; nCount += RecursivelyCountSubdirs(subdirPath); bContinue = dir.GetNext(&name); } @@ -255,7 +255,7 @@ static int RecursivelyCountSubdirs(wxString dirPath) return nCount; } -static int RecursivelyRemoveEmptyDirs(wxString dirPath, +static int RecursivelyRemoveEmptyDirs(const FilePath &dirPath, int nDirCount = 0, ProgressDialog* pProgress = NULL) { @@ -270,7 +270,7 @@ static int RecursivelyRemoveEmptyDirs(wxString dirPath, bContinue = dir.GetFirst(&name, wxEmptyString, wxDIR_DIRS); while (bContinue) { - wxString subdirPath = dirPath + wxFILE_SEP_PATH + name; + FilePath subdirPath = dirPath + wxFILE_SEP_PATH + name; nCount += RecursivelyRemoveEmptyDirs(subdirPath, nDirCount, pProgress); bContinue = dir.GetNext(&name); } @@ -300,7 +300,7 @@ static int RecursivelyRemoveEmptyDirs(wxString dirPath, return nCount; } -static void RecursivelyRemove(wxArrayString& filePathArray, int count, int bias, +static void RecursivelyRemove(const FilePaths& filePathArray, int count, int bias, int flags, const wxChar* message = NULL) { bool bFiles= (flags & kCleanFiles) != 0; @@ -313,8 +313,8 @@ static void RecursivelyRemove(wxArrayString& filePathArray, int count, int bias, progress.create( _("Progress"), message ); auto nn = filePathArray.size(); - for (unsigned int i = 0; i < nn; i++) { - const wxChar *file = filePathArray[i]; + for ( size_t ii = 0; ii < nn; ++ii ) { + const auto &file = filePathArray[ ii ]; if (bFiles) ::wxRemoveFile(file); if (bDirs) { @@ -351,7 +351,7 @@ static void RecursivelyRemove(wxArrayString& filePathArray, int count, int bias, } } if (progress) - progress->Update(i + bias, count); + progress->Update(ii + bias, count); } } @@ -442,7 +442,7 @@ void DirManager::CleanTempDir() // static void DirManager::CleanDir( - const wxString &path, + const FilePath &path, const wxString &dirSpec, const wxString &fileSpec, const wxString &msg, @@ -451,7 +451,7 @@ void DirManager::CleanDir( if (dontDeleteTempFiles) return; // do nothing - wxArrayString filePathArray, dirPathArray; + FilePaths filePathArray, dirPathArray; int countFiles = RecursivelyEnumerate(path, filePathArray, dirSpec, fileSpec, true, false); @@ -477,7 +477,7 @@ void DirManager::CleanDir( namespace { struct PathRestorer { PathRestorer( - bool &commitFlag, wxString &path, wxString &name, wxString &full ) + bool &commitFlag, FilePath &path, FilePath &name, FilePath &full ) : committed( commitFlag ) , projPath( path ) @@ -496,12 +496,12 @@ namespace { } bool &committed; - wxString &projPath, &projName, &projFull; - const wxString oldPath, oldName, oldFull; + FilePath &projPath, &projName, &projFull; + const FilePath oldPath, oldName, oldFull; }; struct DirCleaner { - DirCleaner( bool &commitFlag, const wxString &path ) + DirCleaner( bool &commitFlag, const FilePath &path ) : committed( commitFlag ) , fullPath( path ) {} @@ -517,7 +517,7 @@ namespace { } bool &committed; - wxString fullPath; + FilePath fullPath; }; } @@ -525,7 +525,7 @@ struct DirManager::ProjectSetter::Impl { Impl( DirManager &dm, - wxString& newProjPath, const wxString& newProjName, const bool bCreate, + FilePath& newProjPath, const FilePath& newProjName, const bool bCreate, bool moving ); void Commit(); @@ -545,8 +545,8 @@ struct DirManager::ProjectSetter::Impl // State variables to carry over into Commit() // Remember old path to be cleaned up in case of successful move - wxString oldFull{ dirManager.projFull }; - wxArrayString newPaths; + FilePath oldFull{ dirManager.projFull }; + FilePaths newPaths; size_t trueTotal{ 0 }; bool moving{ true }; @@ -556,7 +556,7 @@ struct DirManager::ProjectSetter::Impl DirManager::ProjectSetter::ProjectSetter( DirManager &dirManager, - wxString& newProjPath, const wxString& newProjName, const bool bCreate, + FilePath& newProjPath, const FilePath& newProjName, const bool bCreate, bool moving ) : mpImpl{ std::make_unique( dirManager, newProjPath, newProjName, bCreate, @@ -583,7 +583,7 @@ void DirManager::ProjectSetter::Commit() DirManager::ProjectSetter::Impl::Impl( DirManager &dm, - wxString& newProjPath, const wxString& newProjName, const bool bCreate, + FilePath& newProjPath, const FilePath& newProjName, const bool bCreate, bool moving_ ) : dirManager{ dm } , moving{ moving_ } @@ -670,7 +670,7 @@ DirManager::ProjectSetter::Impl::Impl( if( progress.Update(newPaths.size(), total) != ProgressResult::Success ) return; - wxString newPath; + FilePath newPath; if (auto b = pair.second.lock()) { auto result = dirManager.LinkOrCopyToNewProjectDirectory( &*b, link ); @@ -773,7 +773,7 @@ void DirManager::ProjectSetter::Impl::Commit() } bool DirManager::SetProject( - wxString& newProjPath, const wxString& newProjName, const bool bCreate) + FilePath& newProjPath, const FilePath& newProjName, const bool bCreate) { ProjectSetter setter{ *this, newProjPath, newProjName, bCreate, true }; if (!setter.Ok()) @@ -782,12 +782,12 @@ bool DirManager::SetProject( return true; } -wxString DirManager::GetProjectDataDir() +FilePath DirManager::GetProjectDataDir() { return projFull; } -wxString DirManager::GetProjectName() +FilePath DirManager::GetProjectName() { return projName; } @@ -813,7 +813,7 @@ wxLongLong DirManager::GetFreeDiskSpace() return freeSpace; } -wxString DirManager::GetDataFilesDir() const +FilePath DirManager::GetDataFilesDir() const { return !projFull.empty()? projFull: mytemp; } @@ -1031,7 +1031,7 @@ void DirManager::BalanceInfoDel(const wxString &file) dirMidPool.erase(midkey); // DELETE the actual directory - wxString dir=(!projFull.empty()? projFull: mytemp); + auto dir = !projFull.empty() ? projFull : mytemp; dir += wxFILE_SEP_PATH; dir += file.Mid(0,3); dir += wxFILE_SEP_PATH; @@ -1197,7 +1197,7 @@ BlockFilePtr DirManager::NewSimpleBlockFile( } BlockFilePtr DirManager::NewAliasBlockFile( - const wxString &aliasedFile, sampleCount aliasStart, + const FilePath &aliasedFile, sampleCount aliasStart, size_t aliasLen, int aliasChannel) { wxFileNameWrapper filePath{ MakeBlockFileName() }; @@ -1214,7 +1214,7 @@ BlockFilePtr DirManager::NewAliasBlockFile( } BlockFilePtr DirManager::NewODAliasBlockFile( - const wxString &aliasedFile, sampleCount aliasStart, + const FilePath &aliasedFile, sampleCount aliasStart, size_t aliasLen, int aliasChannel) { wxFileNameWrapper filePath{ MakeBlockFileName() }; @@ -1231,7 +1231,7 @@ BlockFilePtr DirManager::NewODAliasBlockFile( } BlockFilePtr DirManager::NewODDecodeBlockFile( - const wxString &aliasedFile, sampleCount aliasStart, + const FilePath &aliasedFile, sampleCount aliasStart, size_t aliasLen, int aliasChannel, int decodeType) { wxFileNameWrapper filePath{ MakeBlockFileName() }; @@ -1435,10 +1435,10 @@ bool DirManager::HandleXMLTag(const wxChar *tag, const wxChar **attrs) return true; } -std::pair DirManager::LinkOrCopyToNewProjectDirectory( +std::pair DirManager::LinkOrCopyToNewProjectDirectory( BlockFile *f, bool &link ) { - wxString newPath; + FilePath newPath; auto result = f->GetFileName(); const auto &oldFileNameRef = result.name; @@ -1694,8 +1694,8 @@ int DirManager::ProjectFSCK(const bool bForceError, const bool bAutoRecoverMode) nResult = FSCKstatus_CHANGED | FSCKstatus_SAVE_AUP; } - wxArrayString filePathArray; // *all* files in the project directory/subdirectories - wxString dirPath = (!projFull.empty() ? projFull : mytemp); + FilePaths filePathArray; // *all* files in the project directory/subdirectories + auto dirPath = (!projFull.empty() ? projFull : mytemp); RecursivelyEnumerateWithProgress( dirPath, filePathArray, // output: all files in project directory tree @@ -1936,7 +1936,7 @@ _("Project check of \"%s\" folder \ // // ORPHAN BLOCKFILES (.au and .auf files that are not in the project.) // - wxArrayString orphanFilePathArray; // orphan .au and .auf files + FilePaths orphanFilePathArray; // orphan .au and .auf files this->FindOrphanBlockFiles(filePathArray, orphanFilePathArray); if ((nResult != FSCKstatus_CLOSE_REQ) && !orphanFilePathArray.empty()) @@ -1978,8 +1978,8 @@ other projects. \ // Plus they affect none of the valid tracks, so incorrect to mark them changed, // and no need for refresh. // nResult |= FSCKstatus_CHANGED; - for (size_t i = 0; i < orphanFilePathArray.size(); i++) - wxRemoveFile(orphanFilePathArray[i]); + for ( const auto &orphan : orphanFilePathArray ) + wxRemoveFile(orphan); } } @@ -2112,8 +2112,8 @@ void DirManager::FindMissingAUs( // Find .au and .auf files that are not in the project. void DirManager::FindOrphanBlockFiles( - const wxArrayString& filePathArray, // input: all files in project directory - wxArrayString& orphanFilePathArray) // output: orphan files + const FilePaths &filePathArray, // input: all files in project directory + FilePaths &orphanFilePathArray) // output: orphan files { DirManager *clipboardDM = NULL; @@ -2143,15 +2143,15 @@ void DirManager::FindOrphanBlockFiles( orphanFilePathArray.push_back(fullname.GetFullPath()); } } - for (size_t i = 0; i < orphanFilePathArray.size(); i++) - wxLogWarning(_("Orphan block file: '%s'"), orphanFilePathArray[i]); + for ( const auto &orphan : orphanFilePathArray ) + wxLogWarning(_("Orphan block file: '%s'"), orphan); } void DirManager::RemoveOrphanBlockfiles() { - wxArrayString filePathArray; // *all* files in the project directory/subdirectories - wxString dirPath = (!projFull.empty() ? projFull : mytemp); + FilePaths filePathArray; // *all* files in the project directory/subdirectories + auto dirPath = (!projFull.empty() ? projFull : mytemp); RecursivelyEnumerateWithProgress( dirPath, filePathArray, // output: all files in project directory tree @@ -2161,14 +2161,14 @@ void DirManager::RemoveOrphanBlockfiles() mBlockFileHash.size(), // rough guess of how many BlockFiles will be found/processed, for progress _("Inspecting project file data")); - wxArrayString orphanFilePathArray; + FilePaths orphanFilePathArray; this->FindOrphanBlockFiles( filePathArray, // input: all files in project directory tree orphanFilePathArray); // output: orphan files // Remove all orphan blockfiles. - for (size_t i = 0; i < orphanFilePathArray.size(); i++) - wxRemoveFile(orphanFilePathArray[i]); + for ( const auto &orphan : orphanFilePathArray ) + wxRemoveFile(orphan); } void DirManager::FillBlockfilesCache() diff --git a/src/DirManager.h b/src/DirManager.h index 664bb24d4..20b68424d 100644 --- a/src/DirManager.h +++ b/src/DirManager.h @@ -64,8 +64,8 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { public: ProjectSetter( DirManager &dirManager, - wxString& newProjPath, // assigns it if empty - const wxString& newProjName, const bool bCreate, bool moving); + FilePath& newProjPath, // assigns it if empty + const FilePath& newProjName, const bool bCreate, bool moving); ~ProjectSetter(); bool Ok(); @@ -82,11 +82,11 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { // This function simply creates a ProjectSetter and commits it if successful. // Using ProjectSetter directly allows separation of those steps. bool SetProject( - wxString& newProjPath, // assigns it if empty - const wxString& newProjName, const bool bCreate); + FilePath& newProjPath, // assigns it if empty + const FilePath& newProjName, const bool bCreate); - wxString GetProjectDataDir(); - wxString GetProjectName(); + FilePath GetProjectDataDir(); + FilePath GetProjectName(); wxLongLong GetFreeDiskSpace(); @@ -97,15 +97,15 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { bool allowDeferredWrite = false); BlockFilePtr - NewAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart, + NewAliasBlockFile( const FilePath &aliasedFile, sampleCount aliasStart, size_t aliasLen, int aliasChannel); BlockFilePtr - NewODAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart, + NewODAliasBlockFile( const FilePath &aliasedFile, sampleCount aliasStart, size_t aliasLen, int aliasChannel); BlockFilePtr - NewODDecodeBlockFile( const wxString &aliasedFile, sampleCount aliasStart, + NewODDecodeBlockFile( const FilePath &aliasedFile, sampleCount aliasStart, size_t aliasLen, int aliasChannel, int decodeType); /// Returns true if the blockfile pointed to by b is contained by the DirManager @@ -128,7 +128,7 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { void SaveBlockFile(BlockFile * f, wxTextFile * out); #endif - std::pair + std::pair LinkOrCopyToNewProjectDirectory(BlockFile *f, bool &link); bool EnsureSafeFilename(const wxFileName &fName); @@ -154,7 +154,7 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { // program is exited normally. static void CleanTempDir(); static void CleanDir( - const wxString &path, + const FilePath &path, const wxString &dirSpec, const wxString &fileSpec, const wxString &msg, @@ -176,8 +176,8 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { BlockHash& missingAUHash); // missing data (.au) blockfiles // Find .au and .auf files that are not in the project. void FindOrphanBlockFiles( - const wxArrayString& filePathArray, // input: all files in project directory - wxArrayString& orphanFilePathArray); // output: orphan files + const FilePaths &filePathArray, // input: all files in project directory + FilePaths &orphanFilePathArray); // output: orphan files // Remove all orphaned blockfiles without user interaction. This is @@ -188,7 +188,7 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { // Get directory where data files are in. Note that projects are normally // not interested in this information, but it is important for the // auto-save functionality - wxString GetDataFilesDir() const; + FilePath GetDataFilesDir() const; // This should only be used by the auto save functionality void SetLocalTempDir(const wxString &path); @@ -230,13 +230,13 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { void BalanceFileAdd(int); int BalanceMidAdd(int, int); - wxString projName; - wxString projPath; - wxString projFull; + FilePath projName; + FilePath projPath; + FilePath projFull; wxString lastProject; - wxArrayString aliasList; + FilePaths aliasList; BlockArray *mLoadingTarget; unsigned mLoadingTargetIdx; diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index ecddabad4..75e6ed8fc 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -211,7 +211,7 @@ int ufile_close(AVIOContext *pb) } // Open a file with a (possibly) Unicode filename -int ufile_fopen(AVIOContext **s, const wxString & name, int flags) +int ufile_fopen(AVIOContext **s, const FilePath & name, int flags) { wxFile::OpenMode mode; @@ -250,7 +250,7 @@ int ufile_fopen(AVIOContext **s, const wxString & name, int flags) // Detect type of input file and open it if recognized. Routine // based on the av_open_input_file() libavformat function. -int ufile_fopen_input(std::unique_ptr &context_ptr, wxString & name) +int ufile_fopen_input(std::unique_ptr &context_ptr, FilePath & name) { context_ptr.reset(); auto context = std::make_unique(); diff --git a/src/FFmpeg.h b/src/FFmpeg.h index f16f44257..5f171c7ff 100644 --- a/src/FFmpeg.h +++ b/src/FFmpeg.h @@ -420,8 +420,8 @@ struct FFmpegContext { AVFormatContext *ic_ptr{}; }; -int ufile_fopen(AVIOContext **s, const wxString & name, int flags); -int ufile_fopen_input(std::unique_ptr &context_ptr, wxString & name); +int ufile_fopen(AVIOContext **s, const FilePath & name, int flags); +int ufile_fopen_input(std::unique_ptr &context_ptr, FilePath & name); int ufile_close(AVIOContext *pb); struct streamContext; diff --git a/src/FileNames.cpp b/src/FileNames.cpp index 7176ea592..9eada57d0 100644 --- a/src/FileNames.cpp +++ b/src/FileNames.cpp @@ -24,6 +24,8 @@ used throughout Audacity into this one place. #include "Experimental.h" +#include "MemoryX.h" + #include #include #include @@ -46,7 +48,7 @@ used throughout Audacity into this one place. static wxString gDataDir; bool FileNames::CopyFile( - const wxString& file1, const wxString& file2, bool overwrite) + const FilePath& file1, const FilePath& file2, bool overwrite) { #ifdef __WXMSW__ @@ -71,7 +73,7 @@ bool FileNames::CopyFile( #endif } -bool FileNames::HardLinkFile( const wxString& file1, const wxString& file2 ) +bool FileNames::HardLinkFile( const FilePath& file1, const FilePath& file2 ) { #ifdef __WXMSW__ @@ -106,7 +108,8 @@ wxString FileNames::TempDir() } // originally an ExportMultiple method. Append suffix if newName appears in otherNames. -void FileNames::MakeNameUnique(wxArrayString &otherNames, wxFileName &newName) +void FileNames::MakeNameUnique(FilePaths &otherNames, + wxFileName &newName) { if (otherNames.Index(newName.GetFullName(), false) >= 0) { int i=2; @@ -123,7 +126,7 @@ void FileNames::MakeNameUnique(wxArrayString &otherNames, wxFileName &newName) // // Audacity user data directories -wxString FileNames::AutoSaveDir() +FilePath FileNames::AutoSaveDir() { wxFileName autoSaveDir(FileNames::DataDir(), wxT("AutoSave")); return FileNames::MkDir(autoSaveDir.GetFullPath()); @@ -144,7 +147,7 @@ wxString FileNames::LowerCaseAppNameInPath( const wxString & dirIn){ return dir; } -wxString FileNames::DataDir() +FilePath FileNames::DataDir() { // LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict // between wxStandardPaths and wxConfig under Linux. The latter @@ -182,12 +185,12 @@ wxString FileNames::DataDir() return gDataDir; } -wxString FileNames::ResourcesDir(){ +FilePath FileNames::ResourcesDir(){ wxString resourcesDir( LowerCaseAppNameInPath( wxStandardPaths::Get().GetResourcesDir() )); return resourcesDir; } -wxString FileNames::HtmlHelpDir() +FilePath FileNames::HtmlHelpDir() { #if defined(__WXMAC__) wxFileName exePath(PlatformCompatibility::GetExecutablePath()); @@ -207,43 +210,43 @@ wxString FileNames::HtmlHelpDir() #endif } -wxString FileNames::LegacyChainDir() +FilePath FileNames::LegacyChainDir() { // Don't force creation of it return wxFileName{ DataDir(), wxT("Chains") }.GetFullPath(); } -wxString FileNames::MacroDir() +FilePath FileNames::MacroDir() { return FileNames::MkDir( wxFileName( DataDir(), wxT("Macros") ).GetFullPath() ); } -wxString FileNames::NRPDir() +FilePath FileNames::NRPDir() { return FileNames::MkDir( wxFileName( DataDir(), wxT("NRP") ).GetFullPath() ); } -wxString FileNames::NRPFile() +FilePath FileNames::NRPFile() { return wxFileName( NRPDir(), wxT("noisegate.nrp") ).GetFullPath(); } -wxString FileNames::PlugInDir() +FilePath FileNames::PlugInDir() { return FileNames::MkDir( wxFileName( DataDir(), wxT("Plug-Ins") ).GetFullPath() ); } -wxString FileNames::PluginRegistry() +FilePath FileNames::PluginRegistry() { return wxFileName( DataDir(), wxT("pluginregistry.cfg") ).GetFullPath(); } -wxString FileNames::PluginSettings() +FilePath FileNames::PluginSettings() { return wxFileName( DataDir(), wxT("pluginsettings.cfg") ).GetFullPath(); } -wxString FileNames::BaseDir() +FilePath FileNames::BaseDir() { wxFileName baseDir; @@ -267,7 +270,7 @@ wxString FileNames::BaseDir() return baseDir.GetPath(); } -wxString FileNames::ModulesDir() +FilePath FileNames::ModulesDir() { wxFileName modulesDir(BaseDir(), wxEmptyString); @@ -276,32 +279,32 @@ wxString FileNames::ModulesDir() return modulesDir.GetFullPath(); } -wxString FileNames::ThemeDir() +FilePath FileNames::ThemeDir() { return FileNames::MkDir( wxFileName( DataDir(), wxT("Theme") ).GetFullPath() ); } -wxString FileNames::ThemeComponentsDir() +FilePath FileNames::ThemeComponentsDir() { return FileNames::MkDir( wxFileName( ThemeDir(), wxT("Components") ).GetFullPath() ); } -wxString FileNames::ThemeCachePng() +FilePath FileNames::ThemeCachePng() { return wxFileName( ThemeDir(), wxT("ImageCache.png") ).GetFullPath(); } -wxString FileNames::ThemeCacheHtm() +FilePath FileNames::ThemeCacheHtm() { return wxFileName( ThemeDir(), wxT("ImageCache.htm") ).GetFullPath(); } -wxString FileNames::ThemeImageDefsAsCee() +FilePath FileNames::ThemeImageDefsAsCee() { return wxFileName( ThemeDir(), wxT("ThemeImageDefsAsCee.h") ).GetFullPath(); } -wxString FileNames::ThemeCacheAsCee( ) +FilePath FileNames::ThemeCacheAsCee( ) { // DA: Theme sourcery file name. #ifndef EXPERIMENTAL_DA @@ -311,7 +314,7 @@ wxString FileNames::ThemeCacheAsCee( ) #endif } -wxString FileNames::ThemeComponent(const wxString &Str) +FilePath FileNames::ThemeComponent(const wxString &Str) { return wxFileName( ThemeComponentsDir(), Str, wxT("png") ).GetFullPath(); } @@ -319,7 +322,7 @@ wxString FileNames::ThemeComponent(const wxString &Str) // // Returns the full path of program module (.exe, .dll, .so, .dylib) containing address // -wxString FileNames::PathFromAddr(void *addr) +FilePath FileNames::PathFromAddr(void *addr) { wxFileName name; @@ -413,7 +416,7 @@ wxString FileNames::FindDefaultPath(Operation op) return DefaultToDocumentsFolder(key).GetPath(); } -void FileNames::UpdateDefaultPath(Operation op, const wxString &path) +void FileNames::UpdateDefaultPath(Operation op, const FilePath &path) { if (path.empty()) return; @@ -427,14 +430,14 @@ void FileNames::UpdateDefaultPath(Operation op, const wxString &path) wxString FileNames::SelectFile(Operation op, const wxString& message, - const wxString& default_path, - const wxString& default_filename, + const FilePath& default_path, + const FilePath& default_filename, const wxString& default_extension, const wxString& wildcard, int flags, wxWindow *parent) { - return WithDefaultPath(op, default_path, [&](const wxString &path) { + return WithDefaultPath(op, default_path, [&](const FilePath &path) { return FileSelector( message, path, default_filename, default_extension, wildcard, flags, parent, wxDefaultCoord, wxDefaultCoord); diff --git a/src/FileNames.h b/src/FileNames.h index 354c48fdb..4ccc494e1 100644 --- a/src/FileNames.h +++ b/src/FileNames.h @@ -14,6 +14,8 @@ #include #include "Audacity.h" +#include "audacity/Types.h" + class wxFileName; class wxFileNameWrapper; class wxArrayString; @@ -25,18 +27,19 @@ class AUDACITY_DLL_API FileNames public: // This exists to compensate for bugs in wxCopyFile: static bool CopyFile( - const wxString& file1, const wxString& file2, bool overwrite = true); + const FilePath& file1, const FilePath& file2, bool overwrite = true); // wxWidgets doesn't have a function to do this: make a hard file-system // link if possible. It might not be, as when the paths are on different // storage devices. - static bool HardLinkFile( const wxString& file1, const wxString& file2); + static bool HardLinkFile( const FilePath& file1, const FilePath& file2); static wxString MkDir(const wxString &Str); static wxString TempDir(); // originally an ExportMultiple method. Append suffix if newName appears in otherNames. - static void MakeNameUnique(wxArrayString &otherNames, wxFileName &newName); + static void MakeNameUnique( + FilePaths &otherNames, wxFileName &newName); static wxString LowerCaseAppNameInPath( const wxString & dirIn); /** \brief Audacity user data directory @@ -44,37 +47,37 @@ public: * 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); - static wxString LegacyChainDir(); - static wxString MacroDir(); - static wxString NRPDir(); - static wxString NRPFile(); - static wxString PluginRegistry(); - static wxString PluginSettings(); + static FilePath DataDir(); + static FilePath ResourcesDir(); + static FilePath AutoSaveDir(); + static FilePath HtmlHelpDir(); + static FilePath HtmlHelpIndexFile(bool quick); + static FilePath LegacyChainDir(); + static FilePath MacroDir(); + static FilePath NRPDir(); + static FilePath NRPFile(); + static FilePath PluginRegistry(); + static FilePath PluginSettings(); - static wxString BaseDir(); - static wxString ModulesDir(); + static FilePath BaseDir(); + static FilePath ModulesDir(); /** \brief The user plug-in directory (not a system one) * * This returns the string path to where the user may have put plug-ins * if they don't have system admin rights. Under default settings, it's * /Plug-Ins/ */ - static wxString PlugInDir(); - static wxString ThemeDir(); - static wxString ThemeComponentsDir(); - static wxString ThemeCachePng(); - static wxString ThemeCacheAsCee(); - static wxString ThemeComponent(const wxString &Str); - static wxString ThemeCacheHtm(); - static wxString ThemeImageDefsAsCee(); + static FilePath PlugInDir(); + static FilePath ThemeDir(); + static FilePath ThemeComponentsDir(); + static FilePath ThemeCachePng(); + static FilePath ThemeCacheAsCee(); + static FilePath ThemeComponent(const wxString &Str); + static FilePath ThemeCacheHtm(); + static FilePath ThemeImageDefsAsCee(); // Obtain name of loaded module that contains address - static wxString PathFromAddr(void *addr); + static FilePath PathFromAddr(void *addr); static wxFileNameWrapper DefaultToDocumentsFolder (const wxString &preference); @@ -89,12 +92,12 @@ public: }; static wxString FindDefaultPath(Operation op); - static void UpdateDefaultPath(Operation op, const wxString &path); + static void UpdateDefaultPath(Operation op, const FilePath &path); // F is a function taking a wxString, returning wxString template static wxString WithDefaultPath - (Operation op, const wxString &defaultPath, F function) + (Operation op, const FilePath &defaultPath, F function) { auto path = defaultPath; if (path.empty()) @@ -107,8 +110,10 @@ public: static wxString SelectFile(Operation op, // op matters only when default_path is empty const wxString& message, - const wxString& default_path, - const wxString& default_filename, + const FilePath& default_path, + const FilePath& default_filename, + // empty, or one extension, or multiple extensions joined with + // '|', extensions including the leading dot: const wxString& default_extension, const wxString& wildcard, int flags, diff --git a/src/Languages.cpp b/src/Languages.cpp index ef38ae7ee..af5c72f00 100644 --- a/src/Languages.cpp +++ b/src/Languages.cpp @@ -46,9 +46,9 @@ using LangHash = std::unordered_map; -static bool TranslationExists(wxArrayString &audacityPathList, wxString code) +static bool TranslationExists(const FilePaths &audacityPathList, wxString code) { - wxArrayString results; + FilePaths results; wxGetApp().FindFilesInPathList(wxString::Format(wxT("%s/audacity.mo"), code), audacityPathList, @@ -202,7 +202,7 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames) localLanguageName[code] = name; } - wxArrayString audacityPathList = wxGetApp().audacityPathList; + auto audacityPathList = wxGetApp().audacityPathList; #if defined(__WXGTK__) wxGetApp().AddUniquePathToPathList(wxString::Format(wxT("%s/share/locale"), diff --git a/src/Menus.h b/src/Menus.h index 34350ef57..370737af2 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -11,6 +11,7 @@ #define __AUDACITY_MENUS__ #include "Experimental.h" +#include "audacity/Types.h" #include @@ -100,7 +101,7 @@ MenuManager &GetMenuManager(AudacityProject &project); /// Namespace for functions for File menu namespace FileActions { AudacityProject *DoImportMIDI( - AudacityProject *pProject, const wxString &fileName ); + AudacityProject *pProject, const FilePath &fileName ); } /// Namespace for functions for Edit menu diff --git a/src/ModuleManager.cpp b/src/ModuleManager.cpp index 1a3f69aa2..2224cd761 100755 --- a/src/ModuleManager.cpp +++ b/src/ModuleManager.cpp @@ -85,7 +85,7 @@ wxWindow * MakeHijackPanel() // starts a thread and reads script commands. static tpRegScriptServerFunc scriptFn; -Module::Module(const wxString & name) +Module::Module(const FilePath & name) { mName = name; mLib = std::make_unique(); @@ -212,9 +212,9 @@ ModuleManager::~ModuleManager() // static void ModuleManager::Initialize(CommandHandler &cmdHandler) { - wxArrayString audacityPathList = wxGetApp().audacityPathList; - wxArrayString pathList; - wxArrayString files; + const auto &audacityPathList = wxGetApp().audacityPathList; + FilePaths pathList; + FilePaths files; wxString pathVar; size_t i; @@ -240,7 +240,7 @@ void ModuleManager::Initialize(CommandHandler &cmdHandler) // As a courtesy to some modules that might be bridges to // open other modules, we set the current working // directory to be the module's directory. - wxString prefix = ::wxPathOnly(files[i]); + auto prefix = ::wxPathOnly(files[i]); ::wxSetWorkingDirectory(prefix); #ifdef EXPERIMENTAL_MODULE_PREFS @@ -349,8 +349,8 @@ bool ModuleManager::DiscoverProviders() { InitializeBuiltins(); - wxArrayString provList; - wxArrayString pathList; + FilePaths provList; + FilePaths pathList; // Code from LoadLadspa that might be useful in load modules. wxString pathVar = wxString::FromUTF8(getenv("AUDACITY_MODULES_PATH")); diff --git a/src/ModuleManager.h b/src/ModuleManager.h index 4a8b4fad9..2f3fbc783 100644 --- a/src/ModuleManager.h +++ b/src/ModuleManager.h @@ -48,7 +48,7 @@ typedef int (*fnModuleDispatch)(ModuleDispatchTypes type); class Module { public: - Module(const wxString & name); + Module(const FilePath & name); virtual ~Module(); bool Load(); @@ -57,7 +57,7 @@ public: void * GetSymbol(const wxString &name); private: - wxString mName; + FilePath mName; std::unique_ptr mLib; fnModuleDispatch mDispatch; }; diff --git a/src/PlatformCompatibility.cpp b/src/PlatformCompatibility.cpp index 17f6afea6..c6477a9d9 100644 --- a/src/PlatformCompatibility.cpp +++ b/src/PlatformCompatibility.cpp @@ -23,17 +23,17 @@ #include "PlatformCompatibility.h" -wxString PlatformCompatibility::GetLongFileName(const wxString& shortFileName) +FilePath PlatformCompatibility::GetLongFileName(const FilePath &shortFileName) { wxFileName fn(shortFileName); return fn.GetLongPath(); } -const wxString &PlatformCompatibility::GetExecutablePath() +const FilePath &PlatformCompatibility::GetExecutablePath() { static bool found = false; - static wxString path; + static FilePath path; if (!found) { path = wxStandardPaths::Get().GetExecutablePath(); @@ -44,7 +44,7 @@ const wxString &PlatformCompatibility::GetExecutablePath() return path; } -wxString PlatformCompatibility::ConvertSlashInFileName(const wxString& filePath) +FilePath PlatformCompatibility::ConvertSlashInFileName(const FilePath &filePath) { #ifdef __WXMAC__ wxString path = filePath; diff --git a/src/PlatformCompatibility.h b/src/PlatformCompatibility.h index 47b9aba27..aff0845b6 100644 --- a/src/PlatformCompatibility.h +++ b/src/PlatformCompatibility.h @@ -21,6 +21,7 @@ #define __AUDACITY_COMPATIBILITY__ #include +#include "audacity/Types.h" class PlatformCompatibility { @@ -31,14 +32,14 @@ public: // "C:\PROGRA~1\PROJEC~1.AUP. On other systems, the function // just returns the exact string it is given. // - static wxString GetLongFileName(const wxString& shortFileName); + static FilePath GetLongFileName(const FilePath& shortFileName); // // Get filename and path of executable (e.g. "/usr/bin/audacity" on // Linux or "C:\Program Files\Audacity\Audacity.exe" on Windows) // This string is unchanging // - static const wxString &GetExecutablePath(); + static const FilePath &GetExecutablePath(); // // Audacity treats the / as a file seperator always for Mac OS, @@ -51,7 +52,7 @@ public: // of that directory. This function also exists in the FileDialogPrivate // object // - static wxString ConvertSlashInFileName(const wxString& filePath); + static FilePath ConvertSlashInFileName(const FilePath& filePath); }; #endif diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 64174ac6e..1bf374a8e 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -1472,8 +1472,8 @@ const PluginID & PluginManager::RegisterPlugin(ModuleInterface *provider, Import } void PluginManager::FindFilesInPathList(const wxString & pattern, - const wxArrayString & pathList, - wxArrayString & files, + const FilePaths & pathList, + FilePaths & files, bool directories) { @@ -1487,7 +1487,7 @@ void PluginManager::FindFilesInPathList(const wxString & pattern, // TODO: We REALLY need to figure out the "Audacity" plug-in path(s) - wxArrayString paths; + FilePaths paths; // Add the "per-user" plug-ins directory { @@ -1508,9 +1508,9 @@ void PluginManager::FindFilesInPathList(const wxString & pattern, paths.push_back(ff.GetPath()); // Weed out duplicates - for (size_t i = 0, cnt = pathList.size(); i < cnt; i++) + for (const auto &filePath : pathList) { - ff = pathList[i]; + ff = filePath; const wxString path{ ff.GetFullPath() }; if (paths.Index(path, wxFileName::IsCaseSensitive()) == wxNOT_FOUND) { diff --git a/src/PluginManager.h b/src/PluginManager.h index c2a6c19aa..497b7097c 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -183,8 +183,8 @@ public: const PluginID & RegisterPlugin(ModuleInterface *provider, ImporterInterface *importer) override; void FindFilesInPathList(const wxString & pattern, - const wxArrayString & pathList, - wxArrayString & files, + const FilePaths & pathList, + FilePaths & files, bool directories = false) override; bool HasSharedConfigGroup(const PluginID & ID, const RegistryPath & group) /* not override */; diff --git a/src/Project.cpp b/src/Project.cpp index ef16d5cba..3b9577c82 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -2852,7 +2852,7 @@ wxArrayString AudacityProject::ShowOpenDialog(const wxString &extraformat, const } // static method, can be called outside of a project -bool AudacityProject::IsAlreadyOpen(const wxString & projPathName) +bool AudacityProject::IsAlreadyOpen(const FilePath &projPathName) { const wxFileName newProjPathName(projPathName); size_t numProjects = gAudacityProjects.size(); @@ -2953,7 +2953,7 @@ bool AudacityProject::WarnOfLegacyFile( ) AudacityProject *AudacityProject::OpenProject( - AudacityProject *pProject, const wxString &fileNameArg, bool addtohistory) + AudacityProject *pProject, const FilePath &fileNameArg, bool addtohistory) { AudacityProject *pNewProject = nullptr; if ( ! pProject ) @@ -2969,12 +2969,12 @@ AudacityProject *AudacityProject::OpenProject( // FIXME:? TRAP_ERR This should return a result that is checked. // See comment in AudacityApp::MRUOpen(). -void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory) +void AudacityProject::OpenFile(const FilePath &fileNameArg, bool addtohistory) { // On Win32, we may be given a short (DOS-compatible) file name on rare // occassions (e.g. stuff like "C:\PROGRA~1\AUDACI~1\PROJEC~1.AUP"). We // convert these to long file name first. - wxString fileName = PlatformCompatibility::ConvertSlashInFileName( + auto fileName = PlatformCompatibility::ConvertSlashInFileName( PlatformCompatibility::GetLongFileName(fileNameArg)); // Make sure it isn't already open. @@ -3026,7 +3026,7 @@ void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory) int numRead = ff.Read(buf, 15); if (numRead != 15) { AudacityMessageBox(wxString::Format(_("File may be invalid or corrupted: \n%s"), - (const wxChar*)fileName), _("Error Opening File or Project"), + fileName), _("Error Opening File or Project"), wxOK | wxCENTRE, this); ff.Close(); return; @@ -3459,8 +3459,8 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs) } else if (!wxStrcmp(attr, wxT("projname"))) { - wxString projName; - wxString projPath; + FilePath projName; + FilePath projPath; if (mIsRecovered) { // Fake the filename as if we had opened the original file @@ -3894,7 +3894,7 @@ bool AudacityProject::DoSave (const bool fromSaveAs, } bool success = true; - wxString project, projName, projPath; + FilePath project, projName, projPath; auto cleanup = finally( [&] { if (!safetyFileName.empty()) { @@ -4082,7 +4082,7 @@ bool AudacityProject::DoSave (const bool fromSaveAs, } -bool AudacityProject::SaveCopyWaveTracks(const wxString & strProjectPathName, +bool AudacityProject::SaveCopyWaveTracks(const FilePath & strProjectPathName, const bool bLossless /*= false*/) { wxString extension, fileFormat; @@ -4149,7 +4149,7 @@ bool AudacityProject::SaveCopyWaveTracks(const wxString & strProjectPathName, pWaveTrack->SetPan(0.0); } - wxString strDataDirPathName = strProjectPathName + wxT("_data"); + FilePath strDataDirPathName = strProjectPathName + wxT("_data"); if (!wxFileName::DirExists(strDataDirPathName) && !wxFileName::Mkdir(strDataDirPathName, 0777, wxPATH_MKDIR_FULL)) return false; @@ -4191,7 +4191,7 @@ bool AudacityProject::SaveCopyWaveTracks(const wxString & strProjectPathName, std::vector< std::shared_ptr< Track > > -AudacityProject::AddImportedTracks(const wxString &fileName, +AudacityProject::AddImportedTracks(const FilePath &fileName, TrackHolders &&newTracks) { std::vector< std::shared_ptr< Track > > results; @@ -4304,7 +4304,7 @@ void AudacityProject::ZoomAfterImport(Track *pTrack) } // If pNewTrackList is passed in non-NULL, it gets filled with the pointers to NEW tracks. -bool AudacityProject::Import(const wxString &fileName, WaveTrackArray* pTrackArray /*= NULL*/) +bool AudacityProject::Import(const FilePath &fileName, WaveTrackArray* pTrackArray /*= NULL*/) { TrackHolders newTracks; wxString errorMessage; @@ -4378,7 +4378,7 @@ bool AudacityProject::SaveAs(const wxString & newFileName, bool bWantSaveCopy /* { // This version of SaveAs is invoked only from scripting and does not // prompt for a file name - wxString oldFileName = mFileName; + auto oldFileName = mFileName; bool bOwnsNewAupName = mbLoadedFromAup && (mFileName==newFileName); //check to see if the NEW project file already exists. @@ -4566,7 +4566,7 @@ will be irreversibly overwritten."), fName, fName); } } - wxString oldFileName = mFileName; + auto oldFileName = mFileName; mFileName = fName; bool success = false; auto cleanup = finally( [&] { @@ -5393,8 +5393,7 @@ bool AudacityProject::IsProjectSaved() { // This is true if a project was opened from an .aup // Otherwise it becomes true only when a project is first saved successfully // in DirManager::SetProject - wxString sProjectName = mDirManager->GetProjectName(); - return (!sProjectName.empty()); + return (!mDirManager->GetProjectName().empty()); } // This is done to empty out the tracks, but without creating a new project. @@ -5435,7 +5434,7 @@ bool AudacityProject::SaveFromTimerRecording(wxFileName fnFile) { // MY: To allow SaveAs from Timer Recording we need to check what // the value of mFileName is before we change it. - wxString sOldFilename; + FilePath sOldFilename; if (IsProjectSaved()) { sOldFilename = mFileName; } diff --git a/src/Project.h b/src/Project.h index c8acd4b6a..778e9890e 100644 --- a/src/Project.h +++ b/src/Project.h @@ -276,7 +276,7 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame, */ static wxArrayString ShowOpenDialog(const wxString &extraformat = {}, const wxString &extrafilter = {}); - static bool IsAlreadyOpen(const wxString & projPathName); + static bool IsAlreadyOpen(const FilePath &projPathName); static void OpenFiles(AudacityProject *proj); // Return the given project if that is not NULL, else create a project. @@ -284,9 +284,9 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame, // But if an exception escapes this function, create no NEW project. static AudacityProject *OpenProject( AudacityProject *pProject, - const wxString &fileNameArg, bool addtohistory = true); + const FilePath &fileNameArg, bool addtohistory = true); - void OpenFile(const wxString &fileName, bool addtohistory = true); + void OpenFile(const FilePath &fileName, bool addtohistory = true); private: void EnqueueODTasks(); @@ -297,26 +297,26 @@ public: bool WarnOfLegacyFile( ); // If pNewTrackList is passed in non-NULL, it gets filled with the pointers to NEW tracks. - bool Import(const wxString &fileName, WaveTrackArray *pTrackArray = NULL); + bool Import(const FilePath &fileName, WaveTrackArray *pTrackArray = NULL); void ZoomAfterImport(Track *pTrack); // Takes array of unique pointers; returns array of shared std::vector< std::shared_ptr > - AddImportedTracks(const wxString &fileName, + AddImportedTracks(const FilePath &fileName, TrackHolders &&newTracks); bool Save(); bool SaveAs(bool bWantSaveCopy = false, bool bLossless = false); bool SaveAs(const wxString & newFileName, bool bWantSaveCopy = false, bool addToHistory = true); // strProjectPathName is full path for aup except extension - bool SaveCopyWaveTracks(const wxString & strProjectPathName, bool bLossless = false); + bool SaveCopyWaveTracks(const FilePath & strProjectPathName, bool bLossless = false); private: bool DoSave(bool fromSaveAs, bool bWantSaveCopy, bool bLossless = false); public: - const wxString &GetFileName() { return mFileName; } + const FilePath &GetFileName() { return mFileName; } bool GetDirty() { return mDirty; } void SetProjectTitle( int number =-1); @@ -589,7 +589,7 @@ public: private: // The project's name and file info - wxString mFileName; + FilePath mFileName; // Note: extension-less bool mbLoadedFromAup; std::shared_ptr mDirManager; // MM: DirManager now created dynamically @@ -740,7 +740,7 @@ private: // Dependencies have been imported and a warning should be shown on save bool mImportedDependencies{ false }; - wxArrayString mStrOtherNamesArray; // used to make sure compressed file names are unique + FilePaths mStrOtherNamesArray; // used to make sure compressed file names are unique wxRect mNormalizedWindowState; diff --git a/src/Sequence.cpp b/src/Sequence.cpp index ba73ed162..9f51c65bd 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -713,7 +713,7 @@ void Sequence::InsertSilence(sampleCount s0, sampleCount len) Paste(s0, &sTrack); } -void Sequence::AppendAlias(const wxString &fullPath, +void Sequence::AppendAlias(const FilePath &fullPath, sampleCount start, size_t len, int channel, bool useOD) // STRONG-GUARANTEE @@ -732,7 +732,7 @@ void Sequence::AppendAlias(const wxString &fullPath, mNumSamples += len; } -void Sequence::AppendCoded(const wxString &fName, sampleCount start, +void Sequence::AppendCoded(const FilePath &fName, sampleCount start, size_t len, int channel, int decodeType) // STRONG-GUARANTEE { diff --git a/src/Sequence.h b/src/Sequence.h index 4e893ba9e..d0cb0fa54 100644 --- a/src/Sequence.h +++ b/src/Sequence.h @@ -110,11 +110,11 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ void Append(samplePtr buffer, sampleFormat format, size_t len, XMLWriter* blockFileLog=NULL); void Delete(sampleCount start, sampleCount len); - void AppendAlias(const wxString &fullPath, + void AppendAlias(const FilePath &fullPath, sampleCount start, size_t len, int channel, bool useOD); - void AppendCoded(const wxString &fName, sampleCount start, + void AppendCoded(const FilePath &fName, sampleCount start, size_t len, int channel, int decodeType); ///gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc. diff --git a/src/Theme.cpp b/src/Theme.cpp index f7b7c87a8..c9b51feea 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -593,7 +593,7 @@ class SourceOutputStream final : public wxOutputStream { public: SourceOutputStream(){;}; - int OpenFile(const wxString & Filename); + int OpenFile(const FilePath & Filename); virtual ~SourceOutputStream(); protected: @@ -603,7 +603,7 @@ protected: }; /// Opens the file and also adds a standard comment at the start of it. -int SourceOutputStream::OpenFile(const wxString & Filename) +int SourceOutputStream::OpenFile(const FilePath & Filename) { nBytes = 0; bool bOk; @@ -755,7 +755,7 @@ void ThemeBase::CreateImageCache( bool bBinarySave ) // IF bBinarySave, THEN saving to a normal PNG file. if( bBinarySave ) { - const wxString &FileName = FileNames::ThemeCachePng(); + const auto &FileName = FileNames::ThemeCachePng(); // Perhaps we should prompt the user if they are overwriting // an existing theme cache? @@ -799,7 +799,7 @@ void ThemeBase::CreateImageCache( bool bBinarySave ) else { SourceOutputStream OutStream; - const wxString &FileName = FileNames::ThemeCacheAsCee( ); + const auto &FileName = FileNames::ThemeCacheAsCee( ); if( !OutStream.OpenFile( FileName )) { AudacityMessageBox( @@ -967,7 +967,7 @@ bool ThemeBase::ReadImageCache( teThemeType type, bool bOkIfNotFound) if( type == themeFromFile ) { - const wxString &FileName = FileNames::ThemeCachePng(); + const auto &FileName = FileNames::ThemeCachePng(); if( !wxFileExists( FileName )) { if( bOkIfNotFound ) @@ -1092,7 +1092,7 @@ void ThemeBase::LoadComponents( bool bOkIfNotFound ) wxBusyCursor busy; int i; int n=0; - wxString FileName; + FilePath FileName; for(i = 0; i < (int)mImages.size(); i++) { @@ -1161,7 +1161,7 @@ void ThemeBase::SaveComponents() wxBusyCursor busy; int i; int n=0; - wxString FileName; + FilePath FileName; for(i = 0; i < (int)mImages.size(); i++) { if( (mBitmapFlags[i] & resFlagInternal)==0) diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index a57627a89..3ec136d37 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -493,7 +493,7 @@ bool TimerRecordDialog::HaveFilesToRecover() bool TimerRecordDialog::RemoveAllAutoSaveFiles() { - wxArrayString files; + FilePaths files; wxDir::GetAllFiles(FileNames::AutoSaveDir(), &files, wxT("*.autosave"), wxDIR_FILES); @@ -892,7 +892,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) { wxString sInitialValue; AudacityProject* pProject = GetActiveProject(); - wxString sSaveValue = pProject->GetFileName(); + auto sSaveValue = pProject->GetFileName(); if (!sSaveValue.empty()) { m_fnAutoSaveFile.Assign(sSaveValue); sInitialValue = _("Current Project"); diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index b002782d9..a5c1cbd4a 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -1447,7 +1447,7 @@ void WaveClip::Append(samplePtr buffer, sampleFormat format, } } -void WaveClip::AppendAlias(const wxString &fName, sampleCount start, +void WaveClip::AppendAlias(const FilePath &fName, sampleCount start, size_t len, int channel,bool useOD) // STRONG-GUARANTEE { @@ -1459,7 +1459,7 @@ void WaveClip::AppendAlias(const wxString &fName, sampleCount start, MarkChanged(); } -void WaveClip::AppendCoded(const wxString &fName, sampleCount start, +void WaveClip::AppendCoded(const FilePath &fName, sampleCount start, size_t len, int channel, int decodeType) // STRONG-GUARANTEE { diff --git a/src/WaveClip.h b/src/WaveClip.h index 1b6d869ee..93601c666 100644 --- a/src/WaveClip.h +++ b/src/WaveClip.h @@ -286,10 +286,10 @@ public: /// Flush must be called after last Append void Flush(); - void AppendAlias(const wxString &fName, sampleCount start, + void AppendAlias(const FilePath &fName, sampleCount start, size_t len, int channel,bool useOD); - void AppendCoded(const wxString &fName, sampleCount start, + void AppendCoded(const FilePath &fName, sampleCount start, size_t len, int channel, int decodeType); /// This name is consistent with WaveTrack::Clear. It performs a "Cut" diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 1d657b742..a737d7d60 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -1586,14 +1586,14 @@ void WaveTrack::Append(samplePtr buffer, sampleFormat format, blockFileLog); } -void WaveTrack::AppendAlias(const wxString &fName, sampleCount start, +void WaveTrack::AppendAlias(const FilePath &fName, sampleCount start, size_t len, int channel,bool useOD) // STRONG-GUARANTEE { RightmostOrNewClip()->AppendAlias(fName, start, len, channel, useOD); } -void WaveTrack::AppendCoded(const wxString &fName, sampleCount start, +void WaveTrack::AppendCoded(const FilePath &fName, sampleCount start, size_t len, int channel, int decodeType) // STRONG-GUARANTEE { diff --git a/src/WaveTrack.h b/src/WaveTrack.h index c58c0531c..b0f098fa4 100644 --- a/src/WaveTrack.h +++ b/src/WaveTrack.h @@ -226,14 +226,14 @@ private: /// Flush must be called after last Append void Flush(); - void AppendAlias(const wxString &fName, sampleCount start, + void AppendAlias(const FilePath &fName, sampleCount start, size_t len, int channel,bool useOD); ///for use with On-Demand decoding of compressed files. ///decodeType should be an enum from ODDecodeTask that specifies what ///Type of encoded file this is, such as eODFLAC //vvv Why not use the ODTypeEnum typedef to enforce that for the parameter? - void AppendCoded(const wxString &fName, sampleCount start, + void AppendCoded(const FilePath &fName, sampleCount start, size_t len, int channel, int decodeType); ///gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc. diff --git a/src/blockfile/LegacyAliasBlockFile.cpp b/src/blockfile/LegacyAliasBlockFile.cpp index 0739cedcd..ff049ea84 100644 --- a/src/blockfile/LegacyAliasBlockFile.cpp +++ b/src/blockfile/LegacyAliasBlockFile.cpp @@ -83,7 +83,7 @@ void LegacyAliasBlockFile::SaveXML(XMLWriter &xmlFile) // BuildFromXML methods should always return a BlockFile, not NULL, // even if the result is flawed (e.g., refers to nonexistent file), // as testing will be done in DirManager::ProjectFSCK(). -BlockFilePtr LegacyAliasBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs) +BlockFilePtr LegacyAliasBlockFile::BuildFromXML(const FilePath &projDir, const wxChar **attrs) { wxFileNameWrapper summaryFileName; wxFileNameWrapper aliasFileName; diff --git a/src/blockfile/LegacyAliasBlockFile.h b/src/blockfile/LegacyAliasBlockFile.h index a7dcf1e25..37cb1635c 100644 --- a/src/blockfile/LegacyAliasBlockFile.h +++ b/src/blockfile/LegacyAliasBlockFile.h @@ -35,7 +35,7 @@ class LegacyAliasBlockFile final : public PCMAliasBlockFile BlockFilePtr Copy(wxFileNameWrapper &&fileName) override; void Recover() override; - static BlockFilePtr BuildFromXML(const wxString &projDir, const wxChar **attrs); + static BlockFilePtr BuildFromXML(const FilePath &projDir, const wxChar **attrs); }; #endif diff --git a/src/blockfile/LegacyBlockFile.cpp b/src/blockfile/LegacyBlockFile.cpp index c62712102..73ddb95c5 100644 --- a/src/blockfile/LegacyBlockFile.cpp +++ b/src/blockfile/LegacyBlockFile.cpp @@ -221,7 +221,7 @@ void LegacyBlockFile::SaveXML(XMLWriter &xmlFile) // even if the result is flawed (e.g., refers to nonexistent file), // as testing will be done in DirManager::ProjectFSCK(). /// static -BlockFilePtr LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs, +BlockFilePtr LegacyBlockFile::BuildFromXML(const FilePath &projDir, const wxChar **attrs, size_t len, sampleFormat format) { wxFileNameWrapper fileName; diff --git a/src/blockfile/LegacyBlockFile.h b/src/blockfile/LegacyBlockFile.h index a2fe1c792..b018f518f 100644 --- a/src/blockfile/LegacyBlockFile.h +++ b/src/blockfile/LegacyBlockFile.h @@ -60,7 +60,7 @@ class LegacyBlockFile final : public BlockFile { DiskByteCount GetSpaceUsage() const override; void Recover() override; - static BlockFilePtr BuildFromXML(const wxString &dir, const wxChar **attrs, + static BlockFilePtr BuildFromXML(const FilePath &dir, const wxChar **attrs, size_t len, sampleFormat format); diff --git a/src/commands/LoadCommands.h b/src/commands/LoadCommands.h index b82108eda..4c966c6dd 100644 --- a/src/commands/LoadCommands.h +++ b/src/commands/LoadCommands.h @@ -42,7 +42,7 @@ public: void Terminate() override; FileExtensions GetFileExtensions() override { return {}; } - wxString InstallPath() override { return {}; } + FilePath InstallPath() override { return {}; } bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; diff --git a/src/commands/OpenSaveCommands.cpp b/src/commands/OpenSaveCommands.cpp index a26032934..c903b5fa2 100644 --- a/src/commands/OpenSaveCommands.cpp +++ b/src/commands/OpenSaveCommands.cpp @@ -43,7 +43,7 @@ void OpenProjectCommand::PopulateOrExchange(ShuttleGui & S) bool OpenProjectCommand::Apply(const CommandContext & context){ - wxString oldFileName = context.GetProject()->GetFileName(); + auto oldFileName = context.GetProject()->GetFileName(); if(mFileName.empty()) { auto project = context.GetProject(); @@ -53,7 +53,7 @@ bool OpenProjectCommand::Apply(const CommandContext & context){ { context.GetProject()->OpenFile(mFileName, mbAddToHistory); } - const wxString &newFileName = context.GetProject()->GetFileName(); + const auto &newFileName = context.GetProject()->GetFileName(); // Because Open does not return a success or failure, we have to guess // at this point, based on whether the project file name has diff --git a/src/effects/LoadEffects.h b/src/effects/LoadEffects.h index 97533abba..e950c2aff 100644 --- a/src/effects/LoadEffects.h +++ b/src/effects/LoadEffects.h @@ -41,7 +41,7 @@ public: void Terminate() override; FileExtensions GetFileExtensions() override { return {}; } - wxString InstallPath() override { return {}; } + FilePath InstallPath() override { return {}; } bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 2bc72bed9..ce2bf316a 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -368,7 +368,7 @@ FileExtensions VSTEffectsModule::GetFileExtensions() return {{ _T("vst") }}; } -wxString VSTEffectsModule::InstallPath() +FilePath VSTEffectsModule::InstallPath() { // Not yet ready for VST drag-and-drop... // return FileNames::PlugInDir(); @@ -384,8 +384,8 @@ bool VSTEffectsModule::AutoRegisterPlugins(PluginManagerInterface & WXUNUSED(pm) PluginPaths VSTEffectsModule::FindPluginPaths(PluginManagerInterface & pm) { - wxArrayString pathList; - wxArrayString files; + FilePaths pathList; + FilePaths files; // Check for the VST_PATH environment variable wxString vstpath = wxString::FromUTF8(getenv("VST_PATH")); @@ -499,7 +499,7 @@ unsigned VSTEffectsModule::DiscoverPluginsAtPath( unsigned nFound = 0; errMsg.clear(); // TODO: Fix this for external usage - const wxString &cmdpath = PlatformCompatibility::GetExecutablePath(); + const auto &cmdpath = PlatformCompatibility::GetExecutablePath(); wxString effectIDs = wxT("0;"); wxStringTokenizer effectTzr(effectIDs, wxT(";")); diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index 71cbd5de8..4d27dbe31 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -404,7 +404,7 @@ public: void Terminate() override; FileExtensions GetFileExtensions() override; - wxString InstallPath() override; + FilePath InstallPath() override; bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index 85e2cf451..401497828 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -694,7 +694,7 @@ void AudioUnitEffectImportDialog::PopulateOrExchange(ShuttleGui & S) S.AddStandardButtons(); - wxArrayString presets; + FilePaths presets; // Make sure the user preset directory exists wxString path; diff --git a/src/effects/audiounits/AudioUnitEffect.h b/src/effects/audiounits/AudioUnitEffect.h index b7fe1fb06..0af880515 100644 --- a/src/effects/audiounits/AudioUnitEffect.h +++ b/src/effects/audiounits/AudioUnitEffect.h @@ -243,7 +243,7 @@ public: void Terminate() override; FileExtensions GetFileExtensions() override; - wxString InstallPath() override { return {}; } + FilePath InstallPath() override { return {}; } bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 4e1ee2685..3c1e5ffd7 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -178,7 +178,7 @@ FileExtensions LadspaEffectsModule::GetFileExtensions() }}; } -wxString LadspaEffectsModule::InstallPath() +FilePath LadspaEffectsModule::InstallPath() { // To do: better choice return FileNames::PlugInDir(); @@ -188,8 +188,8 @@ bool LadspaEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) { // Autoregister effects that we "think" are ones that have been shipped with // Audacity. A little simplistic, but it should suffice for now. - wxArrayString pathList = GetSearchPaths(); - wxArrayString files; + auto pathList = GetSearchPaths(); + FilePaths files; wxString ignoredErrMsg; for (int i = 0; i < (int)WXSIZEOF(kShippedEffects); i++) @@ -213,8 +213,8 @@ bool LadspaEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) PluginPaths LadspaEffectsModule::FindPluginPaths(PluginManagerInterface & pm) { - wxArrayString pathList = GetSearchPaths(); - wxArrayString files; + auto pathList = GetSearchPaths(); + FilePaths files; #if defined(__WXMAC__) @@ -328,9 +328,9 @@ void LadspaEffectsModule::DeleteInstance(ComponentInterface *instance) }; } -wxArrayString LadspaEffectsModule::GetSearchPaths() +FilePaths LadspaEffectsModule::GetSearchPaths() { - wxArrayString pathList; + FilePaths pathList; wxString pathVar; // Check for the LADSPA_PATH environment variable diff --git a/src/effects/ladspa/LadspaEffect.h b/src/effects/ladspa/LadspaEffect.h index 875748857..6bc41a4c9 100644 --- a/src/effects/ladspa/LadspaEffect.h +++ b/src/effects/ladspa/LadspaEffect.h @@ -223,7 +223,7 @@ public: void Terminate() override; FileExtensions GetFileExtensions() override; - wxString InstallPath() override; + FilePath InstallPath() override; bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; @@ -239,7 +239,7 @@ public: // LadspaEffectModule implementation - wxArrayString GetSearchPaths(); + FilePaths GetSearchPaths(); private: ModuleManagerInterface *mModMan; diff --git a/src/effects/lv2/LoadLV2.h b/src/effects/lv2/LoadLV2.h index 38948ad82..173bc45f4 100644 --- a/src/effects/lv2/LoadLV2.h +++ b/src/effects/lv2/LoadLV2.h @@ -89,7 +89,7 @@ public: void Terminate() override; FileExtensions GetFileExtensions() override { return {}; } - wxString InstallPath() override { return {}; } + FilePath InstallPath() override { return {}; } bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; diff --git a/src/effects/nyquist/LoadNyquist.cpp b/src/effects/nyquist/LoadNyquist.cpp index cd33212c7..bde88bc9b 100644 --- a/src/effects/nyquist/LoadNyquist.cpp +++ b/src/effects/nyquist/LoadNyquist.cpp @@ -128,7 +128,7 @@ wxString NyquistEffectsModule::GetDescription() bool NyquistEffectsModule::Initialize() { - auto audacityPathList = wxGetApp().audacityPathList; + const auto &audacityPathList = wxGetApp().audacityPathList; for (size_t i = 0, cnt = audacityPathList.size(); i < cnt; i++) { @@ -160,7 +160,7 @@ FileExtensions NyquistEffectsModule::GetFileExtensions() return {{ _T("ny") }}; } -wxString NyquistEffectsModule::InstallPath() +FilePath NyquistEffectsModule::InstallPath() { return FileNames::PlugInDir(); } @@ -169,8 +169,8 @@ bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) { // Autoregister effects that we "think" are ones that have been shipped with // Audacity. A little simplistic, but it should suffice for now. - wxArrayString pathList = NyquistEffect::GetNyquistSearchPath(); - wxArrayString files; + auto pathList = NyquistEffect::GetNyquistSearchPath(); + FilePaths files; wxString ignoredErrMsg; if (!pm.IsPluginRegistered(NYQUIST_PROMPT_ID)) @@ -202,7 +202,7 @@ bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) PluginPaths NyquistEffectsModule::FindPluginPaths(PluginManagerInterface & pm) { auto pathList = NyquistEffect::GetNyquistSearchPath(); - wxArrayString files; + FilePaths files; // Add the Nyquist prompt files.push_back(NYQUIST_PROMPT_ID); diff --git a/src/effects/nyquist/LoadNyquist.h b/src/effects/nyquist/LoadNyquist.h index 2e591e04e..fc0ad49c0 100644 --- a/src/effects/nyquist/LoadNyquist.h +++ b/src/effects/nyquist/LoadNyquist.h @@ -38,7 +38,7 @@ public: void Terminate() override; FileExtensions GetFileExtensions() override; - wxString InstallPath() override; + FilePath InstallPath() override; bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 554972cc7..87019c861 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -2339,10 +2339,10 @@ void NyquistEffect::OSCallback() #endif } -wxArrayString NyquistEffect::GetNyquistSearchPath() +FilePaths NyquistEffect::GetNyquistSearchPath() { - auto audacityPathList = wxGetApp().audacityPathList; - wxArrayString pathList; + const auto &audacityPathList = wxGetApp().audacityPathList; + FilePaths pathList; for (size_t i = 0; i < audacityPathList.size(); i++) { @@ -2977,7 +2977,7 @@ void NyquistEffect::resolveFilePath(wxString& path, wxString extension /* empty path.Trim(true).Trim(false); - typedef std::unordered_map map; + typedef std::unordered_map map; map pathKeys = { {"*home*", wxGetHomeDir()}, {"~", wxGetHomeDir()}, diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index 2e0df8431..5508610ff 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -145,7 +145,7 @@ private: bool IsOk(); const wxString &InitializationError() const { return mInitError; } - static wxArrayString GetNyquistSearchPath(); + static FilePaths GetNyquistSearchPath(); static wxString NyquistToWxString(const char *nyqString); wxString EscapeString(const wxString & inStr); diff --git a/src/effects/vamp/LoadVamp.cpp b/src/effects/vamp/LoadVamp.cpp index 6f50b8216..e5dd265bc 100644 --- a/src/effects/vamp/LoadVamp.cpp +++ b/src/effects/vamp/LoadVamp.cpp @@ -112,6 +112,11 @@ void VampEffectsModule::Terminate() return; } +FileExtensions VampEffectsModule::GetFileExtensions() +{ + return {}; +} + bool VampEffectsModule::AutoRegisterPlugins(PluginManagerInterface & WXUNUSED(pm)) { return false; diff --git a/src/effects/vamp/LoadVamp.h b/src/effects/vamp/LoadVamp.h index f045b76a2..b140b0c32 100644 --- a/src/effects/vamp/LoadVamp.h +++ b/src/effects/vamp/LoadVamp.h @@ -41,8 +41,8 @@ public: bool Initialize() override; void Terminate() override; - FileExtensions GetFileExtensions() override { return {}; } - wxString InstallPath() override { return {}; } + FileExtensions GetFileExtensions() override; + FilePath InstallPath() override { return {}; } bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; diff --git a/src/export/Export.cpp b/src/export/Export.cpp index ca5ab2e04..01ca8f1ec 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -616,7 +616,7 @@ bool Exporter::GetFilename() } } - const auto &ext = mFilename.GetExt(); + auto ext = mFilename.GetExt(); defext = mPlugins[mFormat]->GetExtension(mSubFormat).Lower(); // diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index 704c1b8b5..42a5fe21b 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -638,7 +638,7 @@ ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName, // Figure out how many channels we should export. auto channels = mTracks->GetNumExportChannels(false); - wxArrayString otherNames; // keep track of file names we will use, so we + FilePaths otherNames; // keep track of file names we will use, so we // don't duplicate them ExportKit setting; // the current batch of settings setting.destfile.SetPath(mDir->GetValue()); @@ -754,7 +754,7 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName, bool tagsPrompt = mProject->GetShowId3Dialog(); int l = 0; // track counter auto ok = ProgressResult::Success; - wxArrayString otherNames; + FilePaths otherNames; std::vector exportSettings; // dynamic array we will use to store the // settings needed to do the exports with in exportSettings.reserve(mNumWaveTracks); // Allocate some guessed space to use. diff --git a/src/export/ExportMultiple.h b/src/export/ExportMultiple.h index 923453b5c..4d3d748b9 100644 --- a/src/export/ExportMultiple.h +++ b/src/export/ExportMultiple.h @@ -127,7 +127,7 @@ private: bool mInitialized; // List of file actually exported - wxArrayString mExported; + FilePaths mExported; wxChoice *mFormat; /**< Drop-down list of export formats (combinations of plug-in and subformat) */ diff --git a/src/import/Import.cpp b/src/import/Import.cpp index 85b949686..00d5ddb40 100644 --- a/src/import/Import.cpp +++ b/src/import/Import.cpp @@ -325,7 +325,7 @@ std::unique_ptr Importer::CreateDefaultImportItem() return new_item; } -bool Importer::IsMidi(const wxString &fName) +bool Importer::IsMidi(const FilePath &fName) { const auto extension = fName.AfterLast(wxT('.')); return @@ -335,7 +335,7 @@ bool Importer::IsMidi(const wxString &fName) } // returns number of tracks imported -bool Importer::Import(const wxString &fName, +bool Importer::Import(const FilePath &fName, TrackFactory *trackFactory, TrackHolders &tracks, Tags *tags, diff --git a/src/import/Import.h b/src/import/Import.h index 16d02446c..b8a04206d 100644 --- a/src/import/Import.h +++ b/src/import/Import.h @@ -138,10 +138,10 @@ public: */ std::unique_ptr CreateDefaultImportItem(); - static bool IsMidi(const wxString &fName); + static bool IsMidi(const FilePath &fName); // if false, the import failed and errorMessage will be set. - bool Import(const wxString &fName, + bool Import(const FilePath &fName, TrackFactory *trackFactory, TrackHolders &tracks, Tags *tags, diff --git a/src/import/ImportFFmpeg.cpp b/src/import/ImportFFmpeg.cpp index fe977e6de..1c8286b9d 100644 --- a/src/import/ImportFFmpeg.cpp +++ b/src/import/ImportFFmpeg.cpp @@ -182,7 +182,7 @@ public: wxString GetPluginFormatDescription() override; ///! Probes the file and opens it if appropriate - std::unique_ptr Open(const wxString &Filename) override; + std::unique_ptr Open(const FilePath &Filename) override; }; ///! Does acual import, returned by FFmpegImportPlugin::Open @@ -190,7 +190,7 @@ class FFmpegImportFileHandle final : public ImportFileHandle { public: - FFmpegImportFileHandle(const wxString & name); + FFmpegImportFileHandle(const FilePath & name); ~FFmpegImportFileHandle(); ///! Format initialization @@ -271,7 +271,7 @@ private: bool mCancelled; //!< True if importing was canceled by user bool mStopped; //!< True if importing was stopped by user - wxString mName; + FilePath mName; TrackHolders mChannels; //!< 2-dimensional array of WaveTrack's. //!< First dimension - streams, //!< second - channels of a stream. @@ -295,7 +295,7 @@ wxString FFmpegImportPlugin::GetPluginFormatDescription() return DESC; } -std::unique_ptr FFmpegImportPlugin::Open(const wxString &filename) +std::unique_ptr FFmpegImportPlugin::Open(const FilePath &filename) { auto handle = std::make_unique(filename); @@ -338,7 +338,7 @@ std::unique_ptr FFmpegImportPlugin::Open(const wxString &filen } -FFmpegImportFileHandle::FFmpegImportFileHandle(const wxString & name) +FFmpegImportFileHandle::FFmpegImportFileHandle(const FilePath & name) : ImportFileHandle(name) { PickFFmpegLibs(); diff --git a/src/import/ImportFLAC.cpp b/src/import/ImportFLAC.cpp index c2869d3a8..f4d000366 100644 --- a/src/import/ImportFLAC.cpp +++ b/src/import/ImportFLAC.cpp @@ -140,7 +140,7 @@ class FLACImportPlugin final : public ImportPlugin wxString GetPluginStringID() override { return wxT("libflac"); } wxString GetPluginFormatDescription() override; - std::unique_ptr Open(const wxString &Filename) override; + std::unique_ptr Open(const FilePath &Filename) override; }; @@ -148,7 +148,7 @@ class FLACImportFileHandle final : public ImportFileHandle { friend class MyFLACFile; public: - FLACImportFileHandle(const wxString & name); + FLACImportFileHandle(const FilePath & name); ~FLACImportFileHandle(); bool Init(); @@ -302,7 +302,7 @@ wxString FLACImportPlugin::GetPluginFormatDescription() } -std::unique_ptr FLACImportPlugin::Open(const wxString &filename) +std::unique_ptr FLACImportPlugin::Open(const FilePath &filename) { // First check if it really is a FLAC file @@ -344,7 +344,7 @@ std::unique_ptr FLACImportPlugin::Open(const wxString &filenam } -FLACImportFileHandle::FLACImportFileHandle(const wxString & name) +FLACImportFileHandle::FLACImportFileHandle(const FilePath & name) : ImportFileHandle(name), mSamplesDone(0), mStreamInfoDone(false), diff --git a/src/import/ImportLOF.cpp b/src/import/ImportLOF.cpp index e17e619a8..282234e0c 100644 --- a/src/import/ImportLOF.cpp +++ b/src/import/ImportLOF.cpp @@ -112,14 +112,14 @@ public: wxString GetPluginStringID() override { return wxT("lof"); } wxString GetPluginFormatDescription() override; - std::unique_ptr Open(const wxString &Filename) override; + std::unique_ptr Open(const FilePath &Filename) override; }; class LOFImportFileHandle final : public ImportFileHandle { public: - LOFImportFileHandle(const wxString & name, std::unique_ptr &&file); + LOFImportFileHandle(const FilePath & name, std::unique_ptr &&file); ~LOFImportFileHandle(); wxString GetFileDescription() override; @@ -161,7 +161,7 @@ private: }; LOFImportFileHandle::LOFImportFileHandle - (const wxString & name, std::unique_ptr &&file) + (const FilePath & name, std::unique_ptr &&file) : ImportFileHandle(name), mTextFile(std::move(file)) , mLOFFileName{name} @@ -179,7 +179,7 @@ wxString LOFImportPlugin::GetPluginFormatDescription() return DESC; } -std::unique_ptr LOFImportPlugin::Open(const wxString &filename) +std::unique_ptr LOFImportPlugin::Open(const FilePath &filename) { // Check if it is a binary file { diff --git a/src/import/ImportMIDI.cpp b/src/import/ImportMIDI.cpp index 78d6d71be..c642dab28 100644 --- a/src/import/ImportMIDI.cpp +++ b/src/import/ImportMIDI.cpp @@ -25,7 +25,7 @@ #include "../NoteTrack.h" #include "../widgets/ErrorDialog.h" -bool ImportMIDI(const wxString &fName, NoteTrack * dest) +bool ImportMIDI(const FilePath &fName, NoteTrack * dest) { if (fName.length() <= 4){ AudacityMessageBox( wxString::Format( diff --git a/src/import/ImportMIDI.h b/src/import/ImportMIDI.h index e16bc720a..d1c0a9c02 100644 --- a/src/import/ImportMIDI.h +++ b/src/import/ImportMIDI.h @@ -19,13 +19,14 @@ into a NoteTrack. #define _IMPORT_MIDI_ #include "../Audacity.h" +#include "audacity/Types.h" #if defined(USE_MIDI) class wxString; class NoteTrack; -bool ImportMIDI(const wxString &fName, NoteTrack * dest); +bool ImportMIDI(const FilePath &fName, NoteTrack * dest); class MIDIParser { public: diff --git a/src/import/ImportMP3.cpp b/src/import/ImportMP3.cpp index 0a7a3c0a8..1aa40f15f 100644 --- a/src/import/ImportMP3.cpp +++ b/src/import/ImportMP3.cpp @@ -121,13 +121,13 @@ public: wxString GetPluginStringID() override { return wxT("libmad"); } wxString GetPluginFormatDescription() override; - std::unique_ptr Open(const wxString &Filename) override; + std::unique_ptr Open(const FilePath &Filename) override; }; class MP3ImportFileHandle final : public ImportFileHandle { public: - MP3ImportFileHandle(std::unique_ptr &&file, wxString filename): + MP3ImportFileHandle(std::unique_ptr &&file, const FilePath &filename): ImportFileHandle(filename), mFile(std::move(file)) { @@ -187,7 +187,7 @@ wxString MP3ImportPlugin::GetPluginFormatDescription() return DESC; } -std::unique_ptr MP3ImportPlugin::Open(const wxString &Filename) +std::unique_ptr MP3ImportPlugin::Open(const FilePath &Filename) { auto file = std::make_unique(Filename); diff --git a/src/import/ImportOGG.cpp b/src/import/ImportOGG.cpp index 07837e0f7..cd1e8b3d0 100644 --- a/src/import/ImportOGG.cpp +++ b/src/import/ImportOGG.cpp @@ -93,14 +93,14 @@ public: wxString GetPluginStringID() override { return wxT("liboggvorbis"); } wxString GetPluginFormatDescription() override; - std::unique_ptr Open(const wxString &Filename) override; + std::unique_ptr Open(const FilePath &Filename) override; }; class OggImportFileHandle final : public ImportFileHandle { public: - OggImportFileHandle(const wxString & filename, + OggImportFileHandle(const FilePath & filename, std::unique_ptr &&file, std::unique_ptr &&vorbisFile) : ImportFileHandle(filename), @@ -170,7 +170,7 @@ wxString OggImportPlugin::GetPluginFormatDescription() return DESC; } -std::unique_ptr OggImportPlugin::Open(const wxString &filename) +std::unique_ptr OggImportPlugin::Open(const FilePath &filename) { // Suppress some compiler warnings about unused global variables in the library header wxUnusedVar(OV_CALLBACKS_DEFAULT); diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index f94155a48..900c86405 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -81,14 +81,14 @@ public: wxString GetPluginStringID() override { return wxT("libsndfile"); } wxString GetPluginFormatDescription() override; - std::unique_ptr Open(const wxString &Filename) override; + std::unique_ptr Open(const FilePath &Filename) override; }; class PCMImportFileHandle final : public ImportFileHandle { public: - PCMImportFileHandle(wxString name, SFFile &&file, SF_INFO info); + PCMImportFileHandle(const FilePath &name, SFFile &&file, SF_INFO info); ~PCMImportFileHandle(); wxString GetFileDescription() override; @@ -124,7 +124,7 @@ wxString PCMImportPlugin::GetPluginFormatDescription() return DESC; } -std::unique_ptr PCMImportPlugin::Open(const wxString &filename) +std::unique_ptr PCMImportPlugin::Open(const FilePath &filename) { SF_INFO info; wxFile f; // will be closed when it goes out of scope @@ -188,7 +188,7 @@ std::unique_ptr PCMImportPlugin::Open(const wxString &filename return std::make_unique(filename, std::move(file), info); } -PCMImportFileHandle::PCMImportFileHandle(wxString name, +PCMImportFileHandle::PCMImportFileHandle(const FilePath &name, SFFile &&file, SF_INFO info) : ImportFileHandle(name), mFile(std::move(file)), diff --git a/src/import/ImportPlugin.h b/src/import/ImportPlugin.h index 41308673a..2ccc5d05e 100644 --- a/src/import/ImportPlugin.h +++ b/src/import/ImportPlugin.h @@ -102,7 +102,7 @@ public: // Open the given file, returning true if it is in a recognized // format, false otherwise. This puts the importer into the open // state. - virtual std::unique_ptr Open(const wxString &Filename) = 0; + virtual std::unique_ptr Open(const FilePath &Filename) = 0; virtual ~ImportPlugin() { } @@ -120,7 +120,7 @@ protected: class ImportFileHandle /* not final */ { public: - ImportFileHandle(const wxString & filename) + ImportFileHandle(const FilePath & filename) : mFilename(filename), mProgress{} { @@ -173,7 +173,7 @@ public: virtual void SetStreamUsage(wxInt32 StreamID, bool Use) = 0; protected: - wxString mFilename; + FilePath mFilename; Maybe mProgress; }; diff --git a/src/menus/FileMenus.cpp b/src/menus/FileMenus.cpp index d51f7331c..e21b2d028 100644 --- a/src/menus/FileMenus.cpp +++ b/src/menus/FileMenus.cpp @@ -102,7 +102,7 @@ namespace FileActions { // return null on failure; if success, return the given project, or a NEW // one, if the given was null; create no NEW project if failure AudacityProject *DoImportMIDI( - AudacityProject *pProject, const wxString &fileName) + AudacityProject *pProject, const FilePath &fileName) { auto tracks = pProject->GetTracks(); diff --git a/src/prefs/ModulePrefs.cpp b/src/prefs/ModulePrefs.cpp index cb32eec5f..21bc4ea34 100644 --- a/src/prefs/ModulePrefs.cpp +++ b/src/prefs/ModulePrefs.cpp @@ -141,7 +141,7 @@ bool ModulePrefs::Commit() // static function that tells us about a module. -int ModulePrefs::GetModuleStatus(const wxString &fname){ +int ModulePrefs::GetModuleStatus(const FilePath &fname){ // Default status is NEW module, and we will ask once. int iStatus = kModuleNew; @@ -155,7 +155,7 @@ int ModulePrefs::GetModuleStatus(const wxString &fname){ return iStatus; } -void ModulePrefs::SetModuleStatus(const wxString &fname, int iStatus){ +void ModulePrefs::SetModuleStatus(const FilePath &fname, int iStatus){ wxString ShortName = wxFileName( fname ).GetName(); wxString PrefName = wxString( wxT("/Module/") ) + ShortName.Lower(); gPrefs->Write( PrefName, iStatus ); diff --git a/src/prefs/ModulePrefs.h b/src/prefs/ModulePrefs.h index 33b39b835..d4a6265f6 100644 --- a/src/prefs/ModulePrefs.h +++ b/src/prefs/ModulePrefs.h @@ -40,15 +40,15 @@ class ModulePrefs final : public PrefsPanel wxString HelpPageName() override; void PopulateOrExchange(ShuttleGui & S) override; - static int GetModuleStatus( const wxString &fname ); - static void SetModuleStatus( const wxString &fname, int iStatus ); + static int GetModuleStatus( const FilePath &fname ); + static void SetModuleStatus( const FilePath &fname, int iStatus ); private: void GetAllModuleStatuses(); void Populate(); wxArrayString mModules; std::vector mStatuses; - wxArrayString mPaths; + FilePaths mPaths; }; /// A PrefsPanelFactory that creates one ModulePrefs panel. diff --git a/src/widgets/FileHistory.cpp b/src/widgets/FileHistory.cpp index ad07c0938..deef26f36 100644 --- a/src/widgets/FileHistory.cpp +++ b/src/widgets/FileHistory.cpp @@ -33,7 +33,7 @@ FileHistory::~FileHistory() } // File history management -void FileHistory::AddFileToHistory(const wxString & file, bool update) +void FileHistory::AddFileToHistory(const FilePath & file, bool update) { // Needed to transition from wxFileHistory to FileHistory since there // can be empty history "slots". @@ -82,7 +82,7 @@ void FileHistory::Clear() AddFilesToMenu(); } -const wxString &FileHistory::GetHistoryFile(size_t i) const +const FilePath &FileHistory::GetHistoryFile(size_t i) const { wxASSERT(i < mHistory.size()); @@ -90,7 +90,7 @@ const wxString &FileHistory::GetHistoryFile(size_t i) const return mHistory[i]; } - static const wxString empty; + static const FilePath empty{}; return empty; } diff --git a/src/widgets/FileHistory.h b/src/widgets/FileHistory.h index 365752efb..c60db4e36 100644 --- a/src/widgets/FileHistory.h +++ b/src/widgets/FileHistory.h @@ -21,13 +21,16 @@ #include #include +#include "audacity/Types.h" +#include "../MemoryX.h" + class AUDACITY_DLL_API FileHistory { public: FileHistory(size_t maxfiles = 12, wxWindowID idbase = wxID_FILE); virtual ~FileHistory(); - void AddFileToHistory(const wxString & file, bool update = true); + void AddFileToHistory(const FilePath & file, bool update = true); void RemoveFileFromHistory(size_t i, bool update = true); void Clear(); void UseMenu(wxMenu *menu); @@ -38,7 +41,7 @@ class AUDACITY_DLL_API FileHistory void AddFilesToMenu(wxMenu *menu); size_t GetCount(); - const wxString &GetHistoryFile(size_t i) const; + const FilePath &GetHistoryFile(size_t i) const; private: void Compress(); @@ -47,7 +50,7 @@ class AUDACITY_DLL_API FileHistory wxWindowID mIDBase; std::vector< wxWeakRef< wxMenu > > mMenus; - wxArrayString mHistory; + FilePaths mHistory; }; diff --git a/src/widgets/wxPanelWrapper.h b/src/widgets/wxPanelWrapper.h index fba9045ec..e34923aef 100644 --- a/src/widgets/wxPanelWrapper.h +++ b/src/widgets/wxPanelWrapper.h @@ -15,6 +15,8 @@ #include "../Internat.h" +#include "audacity/Types.h" + void wxTabTraversalWrapperCharHook(wxKeyEvent &event); template @@ -150,8 +152,8 @@ public: FileDialogWrapper( wxWindow *parent, const wxString& message = _("Select a file"), - const wxString& defaultDir = {}, - const wxString& defaultFile = {}, + const FilePath& defaultDir = {}, + const FilePath& defaultFile = {}, const wxString& wildCard = wxFileSelectorDefaultWildcardStr, long style = wxFD_DEFAULT_STYLE, const wxPoint& pos = wxDefaultPosition, @@ -166,8 +168,8 @@ public: void Create( wxWindow *parent, const wxString& message = _("Select a file"), - const wxString& defaultDir = {}, - const wxString& defaultFile = {}, + const FilePath& defaultDir = {}, + const FilePath& defaultFile = {}, const wxString& wildCard = wxFileSelectorDefaultWildcardStr, long style = wxFD_DEFAULT_STYLE, const wxPoint& pos = wxDefaultPosition, diff --git a/src/xml/XMLFileReader.cpp b/src/xml/XMLFileReader.cpp index 520c9d626..2de68609b 100644 --- a/src/xml/XMLFileReader.cpp +++ b/src/xml/XMLFileReader.cpp @@ -38,7 +38,7 @@ XMLFileReader::~XMLFileReader() } bool XMLFileReader::Parse(XMLTagHandler *baseHandler, - const wxString &fname) + const FilePath &fname) { wxFFile theXMLFile(fname, wxT("rb")); if (!theXMLFile.IsOpened()) { diff --git a/src/xml/XMLFileReader.h b/src/xml/XMLFileReader.h index c29f2cb41..301776120 100644 --- a/src/xml/XMLFileReader.h +++ b/src/xml/XMLFileReader.h @@ -14,6 +14,7 @@ #include "expat.h" #include "XMLTagHandler.h" +#include "audacity/Types.h" class AUDACITY_DLL_API XMLFileReader final { public: @@ -21,7 +22,7 @@ class AUDACITY_DLL_API XMLFileReader final { ~XMLFileReader(); bool Parse(XMLTagHandler *baseHandler, - const wxString &fname); + const FilePath &fname); wxString GetErrorStr(); diff --git a/src/xml/XMLTagHandler.cpp b/src/xml/XMLTagHandler.cpp index bd88a7192..b33d8b794 100644 --- a/src/xml/XMLTagHandler.cpp +++ b/src/xml/XMLTagHandler.cpp @@ -59,7 +59,7 @@ bool XMLValueChecker::IsGoodLongString(const wxString & str) // "Good" means the name is well-formed and names an existing file or folder. -bool XMLValueChecker::IsGoodFileName(const wxString & strFileName, const wxString & strDirName /* = {} */) +bool XMLValueChecker::IsGoodFileName(const FilePath & strFileName, const FilePath & strDirName /* = "{} */) { // Test strFileName. if (!IsGoodFileString(strFileName) || @@ -71,7 +71,7 @@ bool XMLValueChecker::IsGoodFileName(const wxString & strFileName, const wxStrin return (fileName.IsOk() && fileName.FileExists()); } -bool XMLValueChecker::IsGoodFileString(const wxString &str) +bool XMLValueChecker::IsGoodFileString(const FilePath &str) { return (IsGoodString(str) && !str.empty() && @@ -83,7 +83,7 @@ bool XMLValueChecker::IsGoodFileString(const wxString &str) (str.Find(wxFileName::GetPathSeparator()) == -1)); // No path separator characters. } -bool XMLValueChecker::IsGoodSubdirName(const wxString & strSubdirName, const wxString & strDirName /* = {} */) +bool XMLValueChecker::IsGoodSubdirName(const FilePath & strSubdirName, const FilePath & strDirName /* = {} */) { // Test strSubdirName. // Note this prevents path separators, and relative path to parents (strDirName), @@ -99,14 +99,14 @@ bool XMLValueChecker::IsGoodSubdirName(const wxString & strSubdirName, const wxS return (fileName.IsOk() && fileName.DirExists()); } -bool XMLValueChecker::IsGoodPathName(const wxString & strPathName) +bool XMLValueChecker::IsGoodPathName(const FilePath & strPathName) { // Test the corresponding wxFileName. wxFileName fileName(strPathName); return XMLValueChecker::IsGoodFileName(fileName.GetFullName(), fileName.GetPath(wxPATH_GET_VOLUME)); } -bool XMLValueChecker::IsGoodPathString(const wxString &str) +bool XMLValueChecker::IsGoodPathString(const FilePath &str) { return (IsGoodString(str) && !str.empty() && diff --git a/src/xml/XMLTagHandler.h b/src/xml/XMLTagHandler.h index 5ffc2b52f..56c37fd39 100644 --- a/src/xml/XMLTagHandler.h +++ b/src/xml/XMLTagHandler.h @@ -22,6 +22,8 @@ #include #include +#include "audacity/Types.h" + #include "XMLWriter.h" class XMLValueChecker { @@ -33,11 +35,11 @@ public: // Labels are allowed to be very long. At some future date we will format long labels nicely. static bool IsGoodLongString(const wxString & str); - static bool IsGoodFileName(const wxString & strFileName, const wxString & strDirName = {}); - static bool IsGoodFileString(const wxString &str); - static bool IsGoodSubdirName(const wxString & strSubdirName, const wxString & strDirName = {}); - static bool IsGoodPathName(const wxString & strPathName); - static bool IsGoodPathString(const wxString &str); + static bool IsGoodFileName(const FilePath & strFileName, const FilePath & strDirName = {}); + static bool IsGoodFileString(const FilePath &str); + static bool IsGoodSubdirName(const FilePath & strSubdirName, const FilePath & strDirName = {}); + static bool IsGoodPathName(const FilePath & strPathName); + static bool IsGoodPathString(const FilePath &str); /** @brief Check that the supplied string can be converted to a long (32bit) * integer. diff --git a/src/xml/XMLWriter.cpp b/src/xml/XMLWriter.cpp index 1b6d4e8b5..9d03af47b 100644 --- a/src/xml/XMLWriter.cpp +++ b/src/xml/XMLWriter.cpp @@ -294,7 +294,7 @@ wxString XMLWriter::XMLEsc(const wxString & s) /// XMLFileWriter class /// XMLFileWriter::XMLFileWriter - ( const wxString &outputPath, const wxString &caption, bool keepBackup ) + ( const FilePath &outputPath, const wxString &caption, bool keepBackup ) : mOutputPath{ outputPath } , mCaption{ caption } , mKeepBackup{ keepBackup } @@ -359,7 +359,7 @@ void XMLFileWriter::PreCommit() void XMLFileWriter::PostCommit() // may throw { - auto tempPath = GetName(); + FilePath tempPath = GetName(); if (mKeepBackup) { if (! mBackupFile.Close() || ! wxRenameFile( mOutputPath, mBackupName ) ) diff --git a/src/xml/XMLWriter.h b/src/xml/XMLWriter.h index a3be8653c..8180c0bb4 100644 --- a/src/xml/XMLWriter.h +++ b/src/xml/XMLWriter.h @@ -16,6 +16,8 @@ #include "../FileException.h" +#include "audacity/Types.h" + /// /// XMLWriter /// @@ -78,7 +80,7 @@ class AUDACITY_DLL_API XMLFileWriter final : private wxFFile, public XMLWriter { /// The caption is for message boxes to show in case of errors. /// Might throw. XMLFileWriter - ( const wxString &outputPath, const wxString &caption, + ( const FilePath &outputPath, const wxString &caption, bool keepBackup = false ); virtual ~XMLFileWriter(); @@ -99,7 +101,7 @@ class AUDACITY_DLL_API XMLFileWriter final : private wxFFile, public XMLWriter { /// Write to file. Might throw. void Write(const wxString &data) override; - wxString GetBackupName() const { return mBackupName; } + FilePath GetBackupName() const { return mBackupName; } private: @@ -113,9 +115,9 @@ class AUDACITY_DLL_API XMLFileWriter final : private wxFFile, public XMLWriter { /// Might throw. void CloseWithoutEndingTags(); // for auto-save files - const wxString mOutputPath; + const FilePath mOutputPath; const wxString mCaption; - wxString mBackupName; + FilePath mBackupName; const bool mKeepBackup; wxFFile mBackupFile;