1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-07 15:22:34 +02:00

Cherry-pick commit with directory checking on unwritable.

Additional cases, when user manualy set directory.
This commit is contained in:
gera 2021-07-14 14:56:25 +03:00 committed by Dmitry Vedenko
parent 41341e12cd
commit c6389ad655
4 changed files with 35 additions and 0 deletions

View File

@ -716,6 +716,22 @@ char *FileNames::VerifyFilename(const wxString &s, bool input)
}
#endif
bool FileNames::WritableLocationCheck(const FilePath& path)
{
bool status = wxFileName::IsDirWritable(path);
if (!status)
{
AudacityMessageBox(
XO("Directory %s does not have write permissions")
.Format(path),
XO("Error"),
wxOK | wxICON_ERROR);
}
return status;
}
// Using this with wxStringArray::Sort will give you a list that
// is alphabetical, without depending on case. If you use the
// default sort, you will get strings with 'R' before 'a', because it is in caps.

View File

@ -221,6 +221,9 @@ namespace FileNames
AUDACITY_DLL_API char *VerifyFilename(const wxString &s, bool input = true);
#endif
//! Check location on writable access and return true if checked successfully.
AUDACITY_DLL_API bool WritableLocationCheck(const FilePath& path);
// wxString compare function for sorting case, which is needed to load correctly.
AUDACITY_DLL_API int CompareNoCase(const wxString& first, const wxString& second);

View File

@ -63,6 +63,11 @@ void DoExport(AudacityProject &project, const FileExtension &format)
// We either use a configured output path,
// or we use the default documents folder - just as for exports.
FilePath pathName = FileNames::FindDefaultPath(FileNames::Operation::MacrosOut);
if (!FileNames::WritableLocationCheck(pathName))
{
return;
}
/*
// If we've gotten to this point, we are in batch mode, have a file format,
// and the project has either been saved or a file has been imported. So, we

View File

@ -38,6 +38,7 @@
#include "../widgets/AudacityMessageBox.h"
#include "../widgets/ReadOnlyText.h"
#include "../widgets/wxTextCtrlWrapper.h"
#include "../FileNames.h"
using namespace FileNames;
using namespace TempDirectory;
@ -295,6 +296,11 @@ void DirectoriesPrefs::OnTempBrowse(wxCommandEvent &evt)
return;
}
if (!FileNames::WritableLocationCheck(dlog.GetPath()))
{
return;
}
// Append an "audacity_temp" directory to this path if necessary (the
// default, the existing pref (as stored in the control), and any path
// ending in a directory with the same name as what we'd add should be OK
@ -371,6 +377,11 @@ void DirectoriesPrefs::OnBrowse(wxCommandEvent &evt)
}
}
if (!FileNames::WritableLocationCheck(dlog.GetPath()))
{
return;
}
tc->SetValue(dlog.GetPath());
}