Audacity  2.2.2
FileNames.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  FileNames.h
6 
7  James Crook
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_FILE_NAMES__
12 #define __AUDACITY_FILE_NAMES__
13 
14 #include <wx/string.h>
15 #include "Audacity.h"
16 
17 class wxFileName;
18 class wxFileNameWrapper;
19 class wxArrayString;
20 
21 // Uh, this is really a namespace rather than a class,
22 // since all the functions are static.
23 class AUDACITY_DLL_API FileNames
24 {
25 public:
26  // This exists to compensate for bugs in wxCopyFile:
27  static bool CopyFile(
28  const wxString& file1, const wxString& file2, bool overwrite = true);
29 
30  static wxString MkDir(const wxString &Str);
31  static wxString TempDir();
32 
33  // originally an ExportMultiple method. Append suffix if newName appears in otherNames.
34  static void MakeNameUnique(wxArrayString &otherNames, wxFileName &newName);
35 
36  static wxString LowerCaseAppNameInPath( const wxString & dirIn);
42  static wxString DataDir();
43  static wxString ResourcesDir();
44  static wxString AutoSaveDir();
45  static wxString HtmlHelpDir();
46  static wxString HtmlHelpIndexFile(bool quick);
47  static wxString LegacyChainDir();
48  static wxString MacroDir();
49  static wxString NRPDir();
50  static wxString NRPFile();
51  static wxString PluginRegistry();
52  static wxString PluginSettings();
53 
54  static wxString BaseDir();
55  static wxString ModulesDir();
56 
62  static wxString PlugInDir();
63  static wxString ThemeDir();
64  static wxString ThemeComponentsDir();
65  static wxString ThemeCachePng();
66  static wxString ThemeCacheAsCee();
67  static wxString ThemeComponent(const wxString &Str);
68  static wxString ThemeCacheHtm();
69  static wxString ThemeImageDefsAsCee();
70 
71  // Obtain name of loaded module that contains address
72  static wxString PathFromAddr(void *addr);
73 
74  static wxFileNameWrapper DefaultToDocumentsFolder
75  (const wxString &preference);
76 
77  // If not None, determines a preference key (for the default path string) to
78  // be read and updated
79  enum class Operation {
80  // _ on None to defeat some macro that is expanding this.
81  _None,
82  Open,
83  Export
84  };
85 
86  static wxString FindDefaultPath(Operation op);
87  static void UpdateDefaultPath(Operation op, const wxString &path);
88 
89  // F is a function taking a wxString, returning wxString
90  template<typename F>
91  static wxString WithDefaultPath
92  (Operation op, const wxString &defaultPath, F function)
93  {
94  auto path = defaultPath;
95  if (path.empty())
96  path = FileNames::FindDefaultPath(op);
97  auto result = function(path);
98  FileNames::UpdateDefaultPath(op, result);
99  return result;
100  }
101 
102  static wxString
103  SelectFile(Operation op, // op matters only when default_path is empty
104  const wxString& message,
105  const wxString& default_path,
106  const wxString& default_filename,
107  const wxString& default_extension,
108  const wxString& wildcard,
109  int flags,
110  wxWindow *parent);
111 
112 private:
113  // Private constructors: No one is ever going to instantiate it.
114  //
115  FileNames(){;};
117 };
118 
119 #endif
static wxString FindDefaultPath(Operation op)
Definition: FileNames.cpp:390
Provides Static functions to yield filenames.
Definition: FileNames.h:23
Main class to control the export function.
static void UpdateDefaultPath(Operation op, const wxString &path)
Definition: FileNames.cpp:399
~FileNames()
Definition: FileNames.h:116