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 ChainDir();
48  static wxString NRPDir();
49  static wxString NRPFile();
50  static wxString PluginRegistry();
51  static wxString PluginSettings();
52 
53  static wxString BaseDir();
54  static wxString ModulesDir();
55 
61  static wxString PlugInDir();
62  static wxString ThemeDir();
63  static wxString ThemeComponentsDir();
64  static wxString ThemeCachePng();
65  static wxString ThemeCacheAsCee();
66  static wxString ThemeComponent(const wxString &Str);
67  static wxString ThemeCacheHtm();
68  static wxString ThemeImageDefsAsCee();
69 
70  // Obtain name of loaded module that contains address
71  static wxString PathFromAddr(void *addr);
72 
73  static wxFileNameWrapper DefaultToDocumentsFolder
74  (const wxString &preference);
75 
76  // If not None, determines a preference key (for the default path string) to
77  // be read and updated
78  enum class Operation {
79  // _ on None to defeat some macro that is expanding this.
80  _None,
81  Open,
82  Export
83  };
84 
85  static wxString FindDefaultPath(Operation op);
86  static void UpdateDefaultPath(Operation op, const wxString &path);
87 
88  // F is a function taking a wxString, returning wxString
89  template<typename F>
90  static wxString WithDefaultPath
91  (Operation op, const wxString &defaultPath, F function)
92  {
93  auto path = defaultPath;
94  if (path.empty())
95  path = FileNames::FindDefaultPath(op);
96  auto result = function(path);
97  FileNames::UpdateDefaultPath(op, result);
98  return result;
99  }
100 
101  static wxString
102  SelectFile(Operation op, // op matters only when default_path is empty
103  const wxString& message,
104  const wxString& default_path,
105  const wxString& default_filename,
106  const wxString& default_extension,
107  const wxString& wildcard,
108  int flags,
109  wxWindow *parent);
110 
111 private:
112  // Private constructors: No one is ever going to instantiate it.
113  //
114  FileNames(){;};
116 };
117 
118 #endif
static wxString FindDefaultPath(Operation op)
Definition: FileNames.cpp:384
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:393
~FileNames()
Definition: FileNames.h:115