Bug 2740 - Directories in Directories preferences can be set to unwritable locations
Add a new function WritableLocationCheck() for checking the directory permissions before setting preferences for Open, Save, Import, Export, Macro Output and Temporary Files directory in Edit->Preferences->Directories and delete the old block of the same test
This commit is contained in:
parent
8d0487ea85
commit
4770b1f0a4
|
@ -267,6 +267,22 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S)
|
|||
S.EndScroller();
|
||||
}
|
||||
|
||||
bool 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 true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void DirectoriesPrefs::OnTempBrowse(wxCommandEvent &evt)
|
||||
{
|
||||
wxString oldTemp = gPrefs->Read(PreferenceKey(Operation::Open, PathType::_None),
|
||||
|
@ -295,6 +311,11 @@ void DirectoriesPrefs::OnTempBrowse(wxCommandEvent &evt)
|
|||
return;
|
||||
}
|
||||
|
||||
if (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,19 +392,9 @@ void DirectoriesPrefs::OnBrowse(wxCommandEvent &evt)
|
|||
}
|
||||
}
|
||||
|
||||
if (evt.GetId() == SaveButtonID || evt.GetId() == ExportButtonID)
|
||||
if (WritableLocationCheck(dlog.GetPath()))
|
||||
{
|
||||
bool Status = wxFileName ::IsDirWritable(dlog.GetPath());
|
||||
wxString path{dlog.GetPath()};
|
||||
if (!Status)
|
||||
{
|
||||
AudacityMessageBox(
|
||||
XO("Directory %s does not have write permissions")
|
||||
.Format(path),
|
||||
XO("Error"),
|
||||
wxOK | wxICON_ERROR);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
tc->SetValue(dlog.GetPath());
|
||||
|
|
Loading…
Reference in New Issue