Audacity  2.2.0
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  static wxString MkDir(const wxString &Str);
27  static wxString TempDir();
28 
29  // originally an ExportMultiple method. Append suffix if newName appears in otherNames.
30  static void MakeNameUnique(wxArrayString &otherNames, wxFileName &newName);
31 
32  static wxString LowerCaseAppNameInPath( const wxString & dirIn);
38  static wxString DataDir();
39  static wxString ResourcesDir();
40  static wxString AutoSaveDir();
41  static wxString HtmlHelpDir();
42  static wxString HtmlHelpIndexFile(bool quick);
43  static wxString ChainDir();
44  static wxString NRPDir();
45  static wxString NRPFile();
46  static wxString PluginRegistry();
47  static wxString PluginSettings();
48 
49  static wxString BaseDir();
50  static wxString ModulesDir();
51 
57  static wxString PlugInDir();
58  static wxString ThemeDir();
59  static wxString ThemeComponentsDir();
60  static wxString ThemeCachePng();
61  static wxString ThemeCacheAsCee();
62  static wxString ThemeComponent(const wxString &Str);
63  static wxString ThemeCacheHtm();
64  static wxString ThemeImageDefsAsCee();
65 
66  // Obtain name of loaded module that contains address
67  static wxString PathFromAddr(void *addr);
68 
69  static wxFileNameWrapper DefaultToDocumentsFolder
70  (const wxString &preference);
71 
72  // If not None, determines a preference key (for the default path string) to
73  // be read and updated
74  enum class Operation {
75  // _ on None to defeat some macro that is expanding this.
76  _None,
77  Open,
78  Export
79  };
80 
81  static wxString FindDefaultPath(Operation op);
82  static void UpdateDefaultPath(Operation op, const wxString &path);
83 
84  // F is a function taking a wxString, returning wxString
85  template<typename F>
86  static wxString WithDefaultPath
87  (Operation op, const wxString &defaultPath, F function)
88  {
89  auto path = defaultPath;
90  if (path.empty())
91  path = FileNames::FindDefaultPath(op);
92  auto result = function(path);
93  FileNames::UpdateDefaultPath(op, result);
94  return result;
95  }
96 
97  static wxString
98  SelectFile(Operation op, // op matters only when default_path is empty
99  const wxString& message,
100  const wxString& default_path,
101  const wxString& default_filename,
102  const wxString& default_extension,
103  const wxString& wildcard,
104  int flags,
105  wxWindow *parent);
106 
107 private:
108  // Private constructors: No one is ever going to instantiate it.
109  //
110  FileNames(){;};
112 };
113 
114 #endif
static wxString FindDefaultPath(Operation op)
Definition: FileNames.cpp:358
Operation
Definition: FileNames.h:74
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:367
Definition: wxFileNameWrapper.h:16
~FileNames()
Definition: FileNames.h:111
FileNames()
Definition: FileNames.h:110