Audacity 3.2.0
Functions
TempDirectory Namespace Reference

Functions

FILES_API wxString TempDir ()
 
FILES_API void ResetTempDir ()
 
FILES_API const FilePathDefaultTempDir ()
 
FILES_API void SetDefaultTempDir (const FilePath &tempDir)
 
FILES_API bool IsTempDirectoryNameOK (const FilePath &Name)
 
FILES_API wxString UnsavedProjectFileName ()
 
FILES_API bool FATFilesystemDenied (const FilePath &path, const TranslatableString &msg, const BasicUI::WindowPlacement &placement={})
 

Function Documentation

◆ DefaultTempDir()

const FilePath & TempDirectory::DefaultTempDir ( )

Definition at line 58 of file TempDirectory.cpp.

59{
60 return sDefaultTempDir;
61}
static FilePath sDefaultTempDir
Default temp directory.

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,
const BasicUI::WindowPlacement placement = {} 
)

Definition at line 115 of file TempDirectory.cpp.

117{
119 {
120 BasicUI::ShowErrorDialog( placement,
121 XO("Unsuitable"),
122 XO("%s\n\nFor tips on suitable drives, click the help button.").Format(msg),
123 "Error:_Unsuitable_drive"
124 );
125
126 return true;
127 }
128
129 return false;
130}
#define XO(s)
Definition: Internat.h:31
Abstract base class used in importing a file.
void ShowErrorDialog(const WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const ErrorDialogOptions &options={})
Show an error dialog with a link to the manual for further help.
Definition: BasicUI.h:241
FILES_API bool IsOnFATFileSystem(const FilePath &path)

References FileNames::IsOnFATFileSystem(), BasicUI::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 70 of file TempDirectory.cpp.

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

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 50 of file TempDirectory.cpp.

51{
52 TempDirPath().clear();
53}
static wxString & TempDirPath()

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 63 of file TempDirectory.cpp.

64{
65 sDefaultTempDir = tempDir;
66}

References sDefaultTempDir.

◆ 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 XO("Unsuitable"),
38 XO("The temporary files directory is on a FAT formatted drive.\n"
39 "Resetting to default location."),
40 "Error:_Unsuitable_drive"
41 );
42
43 path = DefaultTempDir();
44 UpdateDefaultPath(FileNames::Operation::Temp, path);
45 }
46
47 return FileNames::MkDir(path);
48}
FileConfig * gPrefs
Definition: Prefs.cpp:71
FILES_API wxString MkDir(const wxString &Str)
FILES_API wxString PreferenceKey(FileNames::Operation op, FileNames::PathType type)
FILES_API void UpdateDefaultPath(Operation op, const FilePath &path)
FILES_API const FilePath & DefaultTempDir()

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

Referenced by ProjectFileIO::CloseProject(), ProjectFileIO::DiscardConnection(), AudacityApp::InitTempDir(), AutoRecoveryDialog::OnDiscardSelected(), ProjectFileIO::OpenConnection(), AutoRecoveryDialog::PopulateList(), NyquistEffect::Process(), ProjectFileIO::ProjectFileIO(), 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 107 of file TempDirectory.cpp.

108{
109 wxFileName fn(TempDir(),
111
112 return fn.GetFullPath();
113}
static const auto fn
FILES_API wxString CreateUniqueName(const wxString &prefix, const wxString &suffix=wxEmptyString)
FILES_API wxString UnsavedProjectExtension()
FILES_API wxString TempDir()

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

Referenced by ProjectFileIO::OpenConnection(), and ProjectFileManager::OpenNewProject().

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