1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 16:19:43 +02:00

Add additional checks for macro output directory.

This bug still available in case: using old settings file or manual set it into settings file.
This commit is contained in:
gera 2021-07-05 01:25:03 +03:00 committed by Panagiotis Vasilopoulos
parent 7e2b7e68ad
commit a0ea8b63ad
No known key found for this signature in database
GPG Key ID: FD806FDB3B2C5270
4 changed files with 27 additions and 18 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;
@ -267,22 +268,6 @@ 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),
@ -311,7 +296,7 @@ void DirectoriesPrefs::OnTempBrowse(wxCommandEvent &evt)
return;
}
if (WritableLocationCheck(dlog.GetPath()))
if (!FileNames::WritableLocationCheck(dlog.GetPath()))
{
return;
}
@ -392,7 +377,7 @@ void DirectoriesPrefs::OnBrowse(wxCommandEvent &evt)
}
}
if (WritableLocationCheck(dlog.GetPath()))
if (!FileNames::WritableLocationCheck(dlog.GetPath()))
{
return;
}