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:
parent
41341e12cd
commit
c6389ad655
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user