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={})
 
FILES_API Observer::Publisher< FilePath > & GetTempPathObserver ()
 

Function Documentation

◆ DefaultTempDir()

const FilePath & TempDirectory::DefaultTempDir ( )

Definition at line 82 of file TempDirectory.cpp.

83{
84 return sDefaultTempDir;
85}
static FilePath sDefaultTempDir
Default temp directory.

References sDefaultTempDir.

Referenced by audacity::cloud::audiocom::GetUploadTempPath(), AudacityApp::InitTempDir(), anonymous_namespace{PluginMenus.cpp}::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 140 of file TempDirectory.cpp.

142{
144 {
145 BasicUI::ShowErrorDialog( placement,
146 XO("Unsuitable"),
147 XO("%s\n\nFor tips on suitable drives, click the help button.").Format(msg),
148 "Error:_Unsuitable_drive"
149 );
150
151 return true;
152 }
153
154 return false;
155}
XO("Cut/Copy/Paste")
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:264
FILES_API bool IsOnFATFileSystem(const FilePath &path)

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

Referenced by anonymous_namespace{AudioComPrefsPanel.cpp}::AudioComPrefsPanel::Browse(), 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:

◆ GetTempPathObserver()

Observer::Publisher< FilePath > & TempDirectory::GetTempPathObserver ( )

Definition at line 157 of file TempDirectory.cpp.

158{
160}
TempDirChangedPublisher & GetTempDirChangedPublisher()

References anonymous_namespace{TempDirectory.cpp}::GetTempDirChangedPublisher().

Here is the call graph for this function:

◆ IsTempDirectoryNameOK()

bool TempDirectory::IsTempDirectoryNameOK ( const FilePath Name)

Definition at line 95 of file TempDirectory.cpp.

96{
97 if( Name.empty() )
98 return false;
99
100 wxFileName tmpFile;
101 tmpFile.AssignTempFileName(wxT("nn"));
102 // use Long Path to expand out any abbreviated long substrings.
103 wxString BadPath = tmpFile.GetLongPath();
104 ::wxRemoveFile(tmpFile.GetFullPath());
105
106#ifdef __WXMAC__
107 // This test is to fix bug 1220 on a 1.x to 2.x to 2.1.3 upgrade.
108 // It is less permissive than we could be as it stops a path
109 // with this string ANYWHERE within it rather than excluding just
110 // the paths that the earlier Audacities used to create.
111 if( Name.Contains( "/tmp/") )
112 return false;
113 BadPath = BadPath.BeforeLast( '/' ) + "/";
114 wxFileName cmpFile( Name );
115 wxString NameCanonical = cmpFile.GetLongPath( ) + "/";
116#else
117 BadPath = BadPath.BeforeLast( '\\' ) + "\\";
118 wxFileName cmpFile( Name );
119 wxString NameCanonical = cmpFile.GetLongPath( ) + "\\";
120#endif
121
122 if (FATFilesystemDenied(NameCanonical,
123 XO("The temporary files directory is on a FAT formatted drive.\n"
124 "Resetting to default location.")))
125 {
126 return false;
127 }
128
129 return !(NameCanonical.StartsWith( BadPath ));
130}
wxT("CloseDown"))
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:175

References anonymous_namespace{Registry.cpp}::BadPath(), FATFilesystemDenied(), wxT(), 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 74 of file TempDirectory.cpp.

75{
76 TempDirPath().clear();
77}
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 87 of file TempDirectory.cpp.

References anonymous_namespace{TempDirectory.cpp}::GetTempDirChangedPublisher(), sDefaultTempDir, and anonymous_namespace{TempDirectory.cpp}::TempDirChangedPublisher::UpdateTempPath().

Here is the call 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 50 of file TempDirectory.cpp.

51{
52 auto &path = TempDirPath();
53 if (gPrefs && path.empty())
54 path =
55 gPrefs->Read(PreferenceKey(FileNames::Operation::Temp,
56 FileNames::PathType::_None), wxT(""));
57
59 {
61 XO("Unsuitable"),
62 XO("The temporary files directory is on a FAT formatted drive.\n"
63 "Resetting to default location."),
64 "Error:_Unsuitable_drive"
65 );
66
67 path = DefaultTempDir();
68 UpdateDefaultPath(FileNames::Operation::Temp, path);
69 }
70
71 return FileNames::MkDir(path);
72}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
virtual bool Read(const wxString &key, bool *value) const =0
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(), audacity::BasicSettings::Read(), BasicUI::ShowErrorDialog(), TempDirPath(), FileNames::UpdateDefaultPath(), wxT(), 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 132 of file TempDirectory.cpp.

133{
134 wxFileName fn(TempDir(),
136
137 return fn.GetFullPath();
138}
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(), FileNames::UnsavedProjectExtension(), and wxT().

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

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