1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 08:39:46 +02:00

Make FileNames a namespace (fixing Windows build)...

... as the comment said it should be.
This commit is contained in:
Paul Licameli 2019-12-30 11:09:46 -05:00
parent de4edb0424
commit dbdfb26e4a

View File

@ -21,11 +21,8 @@
class wxFileName;
class wxFileNameWrapper;
// Uh, this is really a namespace rather than a class,
// since all the functions are static.
class AUDACITY_DLL_API FileNames
namespace FileNames
{
public:
// A description of a type of file
struct FileType {
FileType() = default;
@ -44,7 +41,7 @@ public:
};
// Frequently used types
static const FileType
extern const FileType
AllFiles // *
, AudacityProjects // *.aup
, DynamicLibraries // depends on the operating system
@ -55,25 +52,25 @@ public:
// Convert fileTypes into a single string as expected by wxWidgets file
// selection dialog
static wxString FormatWildcard( const FileTypes &fileTypes );
wxString FormatWildcard( const FileTypes &fileTypes );
// This exists to compensate for bugs in wxCopyFile:
static bool CopyFile(
bool CopyFile(
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 FilePath& file1, const FilePath& file2);
bool HardLinkFile( const FilePath& file1, const FilePath& file2);
static wxString MkDir(const wxString &Str);
static wxString TempDir();
wxString MkDir(const wxString &Str);
wxString TempDir();
static const FilePath &DefaultTempDir();
static void SetDefaultTempDir( const FilePath &tempDir );
static bool IsTempDirectoryNameOK( const FilePath & Name );
const FilePath &DefaultTempDir();
void SetDefaultTempDir( const FilePath &tempDir );
bool IsTempDirectoryNameOK( const FilePath & Name );
static bool IsMidi(const FilePath &fName);
bool IsMidi(const FilePath &fName);
/** \brief A list of directories that should be searched for Audacity files
* (plug-ins, help files, etc.).
@ -83,53 +80,53 @@ public:
* 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. */
static const FilePaths &AudacityPathList();
static void SetAudacityPathList( FilePaths list );
const FilePaths &AudacityPathList();
void SetAudacityPathList( FilePaths list );
// originally an ExportMultipleDialog method. Append suffix if newName appears in otherNames.
static void MakeNameUnique(
void MakeNameUnique(
FilePaths &otherNames, wxFileName &newName);
static wxString LowerCaseAppNameInPath( const wxString & dirIn);
wxString LowerCaseAppNameInPath( const wxString & dirIn);
/** \brief Audacity user data directory
*
* Where audacity keeps it's settings and other user data squirreled away,
* by default ~/.audacity-data/ on Unix, Application Data/Audacity on
* windows system */
static 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();
FilePath DataDir();
FilePath ResourcesDir();
FilePath AutoSaveDir();
FilePath HtmlHelpDir();
FilePath HtmlHelpIndexFile(bool quick);
FilePath LegacyChainDir();
FilePath MacroDir();
FilePath NRPDir();
FilePath NRPFile();
FilePath PluginRegistry();
FilePath PluginSettings();
static FilePath BaseDir();
static FilePath ModulesDir();
FilePath BaseDir();
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
* <DataDir>/Plug-Ins/ */
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();
FilePath PlugInDir();
FilePath ThemeDir();
FilePath ThemeComponentsDir();
FilePath ThemeCachePng();
FilePath ThemeCacheAsCee();
FilePath ThemeComponent(const wxString &Str);
FilePath ThemeCacheHtm();
FilePath ThemeImageDefsAsCee();
// Obtain name of loaded module that contains address
static FilePath PathFromAddr(void *addr);
FilePath PathFromAddr(void *addr);
static bool IsPathAvailable( const FilePath & Path);
static wxFileNameWrapper DefaultToDocumentsFolder
bool IsPathAvailable( const FilePath & Path);
wxFileNameWrapper DefaultToDocumentsFolder
(const wxString &preference);
// If not None, determines a preference key (for the default path string) to
@ -141,12 +138,12 @@ public:
Export
};
static wxString FindDefaultPath(Operation op);
static void UpdateDefaultPath(Operation op, const FilePath &path);
wxString FindDefaultPath(Operation op);
void UpdateDefaultPath(Operation op, const FilePath &path);
// F is a function taking a wxString, returning wxString
template<typename F>
static wxString WithDefaultPath
wxString WithDefaultPath
(Operation op, const FilePath &defaultPath, F function)
{
auto path = defaultPath;
@ -157,7 +154,7 @@ public:
return result;
}
static wxString
wxString
SelectFile(Operation op, // op matters only when default_path is empty
const TranslatableString& message,
const FilePath& default_path,
@ -168,11 +165,11 @@ public:
wxWindow *parent);
// Useful functions for working with search paths
static void AddUniquePathToPathList(const FilePath &path,
void AddUniquePathToPathList(const FilePath &path,
FilePaths &pathList);
static void AddMultiPathsToPathList(const wxString &multiPathString,
void AddMultiPathsToPathList(const wxString &multiPathString,
FilePaths &pathList);
static void FindFilesInPathList(const wxString & pattern,
void FindFilesInPathList(const wxString & pattern,
const FilePaths & pathList,
FilePaths &results,
int flags = wxDIR_FILES);
@ -180,17 +177,11 @@ public:
/** \brief Protect against Unicode to multi-byte conversion failures
* on Windows */
#if defined(__WXMSW__)
static char *VerifyFilename(const wxString &s, bool input = true);
char *VerifyFilename(const wxString &s, bool input = true);
// stuff for file name sanitisation
static wxCharBuffer mFilename;
wxCharBuffer mFilename;
#endif
private:
// Private constructors: No one is ever going to instantiate it.
//
FileNames(){;};
~FileNames(){;};
};
// Use this macro to wrap all filenames and pathnames that get