1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 14:02:57 +02:00

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)
This commit is contained in:
Paul Licameli
2019-03-07 14:50:22 -05:00
parent 485b6bb425
commit a30000cf74
80 changed files with 371 additions and 342 deletions

View File

@@ -24,6 +24,8 @@ used throughout Audacity into this one place.
#include "Experimental.h"
#include "MemoryX.h"
#include <wx/defs.h>
#include <wx/filename.h>
#include <wx/intl.h>
@@ -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);