Audacity  3.0.3
Functions
TempDirectory Namespace Reference

Functions

AUDACITY_DLL_API wxString TempDir ()
 
AUDACITY_DLL_API void ResetTempDir ()
 
AUDACITY_DLL_API const FilePathDefaultTempDir ()
 
AUDACITY_DLL_API void SetDefaultTempDir (const FilePath &tempDir)
 
AUDACITY_DLL_API bool IsTempDirectoryNameOK (const FilePath &Name)
 
AUDACITY_DLL_API wxString UnsavedProjectFileName ()
 
AUDACITY_DLL_API bool FATFilesystemDenied (const FilePath &path, const TranslatableString &msg, wxWindow *window=nullptr)
 

Function Documentation

◆ DefaultTempDir()

const FilePath & TempDirectory::DefaultTempDir ( )

Definition at line 59 of file TempDirectory.cpp.

60 {
61  return sDefaultTempDir;
62 }

References sDefaultTempDir.

Referenced by AudacityApp::InitTempDir(), PluginActions::Handler::OnResetConfig(), DirectoriesPrefs::OnTempBrowse(), and TempDir().

Here is the caller graph for this function:

◆ FATFilesystemDenied()

bool TempDirectory::FATFilesystemDenied ( const FilePath path,
const TranslatableString msg,
wxWindow *  window = nullptr 
)

Definition at line 116 of file TempDirectory.cpp.

119 {
121  {
123  window,
124  XO("Unsuitable"),
125  XO("%s\n\nFor tips on suitable drives, click the help button.").Format(msg),
126  "Error:_Unsuitable_drive"
127  );
128 
129  return true;
130  }
131 
132  return false;
133 }

References FileNames::IsOnFATFileSystem(), ShowErrorDialog(), and XO.

Referenced by ProjectFileManager::DoSave(), IsTempDirectoryNameOK(), DirectoriesPrefs::OnBrowse(), FilesystemValidator::OnChar(), DirectoriesPrefs::OnTempBrowse(), ProjectFileManager::OpenFile(), ProjectFileManager::SaveCopy(), and FilesystemValidator::Validate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsTempDirectoryNameOK()

bool TempDirectory::IsTempDirectoryNameOK ( const FilePath Name)

Definition at line 71 of file TempDirectory.cpp.

72 {
73  if( Name.empty() )
74  return false;
75 
76  wxFileName tmpFile;
77  tmpFile.AssignTempFileName(wxT("nn"));
78  // use Long Path to expand out any abbreviated long substrings.
79  wxString BadPath = tmpFile.GetLongPath();
80  ::wxRemoveFile(tmpFile.GetFullPath());
81 
82 #ifdef __WXMAC__
83  // This test is to fix bug 1220 on a 1.x to 2.x to 2.1.3 upgrade.
84  // It is less permissive than we could be as it stops a path
85  // with this string ANYWHERE within it rather than excluding just
86  // the paths that the earlier Audacities used to create.
87  if( Name.Contains( "/tmp/") )
88  return false;
89  BadPath = BadPath.BeforeLast( '/' ) + "/";
90  wxFileName cmpFile( Name );
91  wxString NameCanonical = cmpFile.GetLongPath( ) + "/";
92 #else
93  BadPath = BadPath.BeforeLast( '\\' ) + "\\";
94  wxFileName cmpFile( Name );
95  wxString NameCanonical = cmpFile.GetLongPath( ) + "\\";
96 #endif
97 
98  if (FATFilesystemDenied(NameCanonical,
99  XO("The temporary files directory is on a FAT formatted drive.\n"
100  "Resetting to default location.")))
101  {
102  return false;
103  }
104 
105  return !(NameCanonical.StartsWith( BadPath ));
106 }

References anonymous_namespace{Registry.cpp}::BadPath(), FATFilesystemDenied(), and XO.

Referenced by AudacityApp::InitTempDir(), DirectoriesPrefs::OnTempBrowse(), and DirectoriesPrefs::Validate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetTempDir()

void TempDirectory::ResetTempDir ( )

Definition at line 51 of file TempDirectory.cpp.

52 {
53  TempDirPath().clear();
54 }

References TempDirPath().

Referenced by AudacityApp::InitTempDir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDefaultTempDir()

void TempDirectory::SetDefaultTempDir ( const FilePath tempDir)

Definition at line 64 of file TempDirectory.cpp.

65 {
66  sDefaultTempDir = tempDir;
67 }

References sDefaultTempDir.

Referenced by AudacityApp::OnInit().

Here is the caller graph for this function:

◆ TempDir()

wxString TempDirectory::TempDir ( )

Returns the directory used for temp files.

Todo:
put a counter in here to see if it gets used a lot. if it does, then maybe we should cache the path name each time.

Definition at line 26 of file TempDirectory.cpp.

27 {
28  auto &path = TempDirPath();
29  if (gPrefs && path.empty())
30  path =
31  gPrefs->Read(PreferenceKey(FileNames::Operation::Temp,
32  FileNames::PathType::_None), wxT(""));
33 
35  {
37  nullptr,
38  XO("Unsuitable"),
39  XO("The temporary files directory is on a FAT formatted drive.\n"
40  "Resetting to default location."),
41  "Error:_Unsuitable_drive"
42  );
43 
44  path = DefaultTempDir();
45  UpdateDefaultPath(FileNames::Operation::Temp, path);
46  }
47 
48  return FileNames::MkDir(path);
49 }

References DefaultTempDir(), gPrefs, FileNames::IsOnFATFileSystem(), FileNames::MkDir(), FileNames::PreferenceKey(), ShowErrorDialog(), TempDirPath(), FileNames::UpdateDefaultPath(), and XO.

Referenced by AudacityProject::AudacityProject(), ProjectFileIO::CloseProject(), ProjectFileIO::DiscardConnection(), AudacityApp::InitTempDir(), AutoRecoveryDialog::OnDiscardSelected(), ProjectFileIO::OpenConnection(), AutoRecoveryDialog::PopulateList(), NyquistEffect::Process(), UnsavedProjectFileName(), and DirectoriesPrefs::Validate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnsavedProjectFileName()

wxString TempDirectory::UnsavedProjectFileName ( )

Definition at line 108 of file TempDirectory.cpp.

109 {
110  wxFileName fn(TempDir(),
112 
113  return fn.GetFullPath();
114 }

References FileNames::CreateUniqueName(), fn, TempDir(), and FileNames::UnsavedProjectExtension().

Referenced by ProjectFileIO::OpenConnection().

Here is the call graph for this function:
Here is the caller graph for this function:
FileNames::UnsavedProjectExtension
AUDACITY_DLL_API wxString UnsavedProjectExtension()
TempDirectory::DefaultTempDir
AUDACITY_DLL_API const FilePath & DefaultTempDir()
Definition: TempDirectory.cpp:59
fn
static const auto fn
Definition: WaveformView.cpp:1102
sDefaultTempDir
static FilePath sDefaultTempDir
Default temp directory.
Definition: TempDirectory.cpp:57
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:68
FileNames::UpdateDefaultPath
AUDACITY_DLL_API void UpdateDefaultPath(Operation op, const FilePath &path)
Format
Abstract base class used in importing a file.
XO
#define XO(s)
Definition: Internat.h:31
FileNames::MkDir
AUDACITY_DLL_API wxString MkDir(const wxString &Str)
FileNames::IsOnFATFileSystem
AUDACITY_DLL_API bool IsOnFATFileSystem(const FilePath &path)
ShowErrorDialog
void ShowErrorDialog(wxWindow *parent, const TranslatableString &dlogTitle, const TranslatableString &message, const wxString &helpPage, const bool Close, const wxString &log)
Displays an error dialog with a button that offers help.
Definition: ErrorDialog.cpp:152
FileNames::CreateUniqueName
AUDACITY_DLL_API wxString CreateUniqueName(const wxString &prefix, const wxString &suffix=wxEmptyString)
FileNames::PreferenceKey
AUDACITY_DLL_API wxString PreferenceKey(FileNames::Operation op, FileNames::PathType type)
TempDirPath
static wxString & TempDirPath()
Definition: TempDirectory.cpp:16
TempDirectory::FATFilesystemDenied
AUDACITY_DLL_API bool FATFilesystemDenied(const FilePath &path, const TranslatableString &msg, wxWindow *window=nullptr)
Definition: TempDirectory.cpp:116
anonymous_namespace{Registry.cpp}::BadPath
void BadPath(const TranslatableString &format, const wxString &key, const Identifier &name)
Definition: Registry.cpp:166
TempDirectory::TempDir
AUDACITY_DLL_API wxString TempDir()
Definition: TempDirectory.cpp:26