Sweep for filename copying: prefs and effects
This commit is contained in:
parent
c3cca71461
commit
2d7e21536e
|
@ -1391,16 +1391,15 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append)
|
|||
gPrefs->Read(wxT("/Effects/Equalization/PresetVersion"), &eqCurvesInstalledVersion, wxT(""));
|
||||
|
||||
bool needUpdate = (eqCurvesCurrentVersion != eqCurvesInstalledVersion);
|
||||
|
||||
|
||||
// UpdateDefaultCurves allows us to import new factory presets only,
|
||||
// or update all factory preset curves.
|
||||
if (needUpdate)
|
||||
UpdateDefaultCurves( UPDATE_ALL != 0 );
|
||||
fn = wxFileName( FileNames::DataDir(), wxT("EQCurves.xml") );
|
||||
}
|
||||
else {
|
||||
fn = wxFileName(fileName); // user is loading a specific set of curves
|
||||
}
|
||||
else
|
||||
fn = fileName; // user is loading a specific set of curves
|
||||
|
||||
// If requested file doesn't exist...
|
||||
if( !fn.FileExists() && !GetDefaultFileName(fn) ) {
|
||||
|
@ -1420,11 +1419,12 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append)
|
|||
|
||||
// Load the curves
|
||||
XMLFileReader reader;
|
||||
if( !reader.Parse( this, fn.GetFullPath() ) )
|
||||
const wxString fullPath{ fn.GetFullPath() };
|
||||
if( !reader.Parse( this, fullPath ) )
|
||||
{
|
||||
wxString msg;
|
||||
/* i18n-hint: EQ stands for 'Equalization'.*/
|
||||
msg.Printf(_("Error Loading EQ Curves from file:\n%s\nError message says:\n%s"), fn.GetFullPath().c_str(), reader.GetErrorStr().c_str());
|
||||
msg.Printf(_("Error Loading EQ Curves from file:\n%s\nError message says:\n%s"), fullPath.c_str(), reader.GetErrorStr().c_str());
|
||||
// Inform user of load failure
|
||||
wxMessageBox( msg,
|
||||
_("Error Loading EQ Curves"),
|
||||
|
@ -1635,14 +1635,15 @@ void EffectEqualization::SaveCurves(const wxString &fileName)
|
|||
}
|
||||
}
|
||||
else
|
||||
fn = wxFileName(fileName);
|
||||
fn = fileName;
|
||||
|
||||
// Create/Open the file
|
||||
XMLFileWriter eqFile;
|
||||
const wxString fullPath{ fn.GetFullPath() };
|
||||
|
||||
try
|
||||
{
|
||||
eqFile.Open( fn.GetFullPath(), wxT("wb") );
|
||||
eqFile.Open( fullPath, wxT("wb") );
|
||||
|
||||
// Write the curves
|
||||
WriteXML( eqFile );
|
||||
|
@ -1654,7 +1655,7 @@ void EffectEqualization::SaveCurves(const wxString &fileName)
|
|||
{
|
||||
wxMessageBox(wxString::Format(
|
||||
_("Couldn't write to file \"%s\": %s"),
|
||||
fn.GetFullPath().c_str(), exception.GetMessage().c_str()),
|
||||
fullPath.c_str(), exception.GetMessage().c_str()),
|
||||
_("Error Saving Equalization Curves"), wxICON_ERROR, mUIParent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -453,7 +453,7 @@ wxArrayString VSTEffectsModule::FindPlugins(PluginManagerInterface & pm)
|
|||
bool VSTEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxString & path)
|
||||
{
|
||||
// TODO: Fix this for external usage
|
||||
wxString cmdpath = PlatformCompatibility::GetExecutablePath();
|
||||
const wxString &cmdpath = PlatformCompatibility::GetExecutablePath();
|
||||
|
||||
wxString effectIDs = wxT("0;");
|
||||
wxStringTokenizer effectTzr(effectIDs, wxT(";"));
|
||||
|
@ -2198,8 +2198,7 @@ bool VSTEffect::Load()
|
|||
}
|
||||
if (mName.length() == 0)
|
||||
{
|
||||
wxFileName f(realPath);
|
||||
mName = f.GetName();
|
||||
mName = wxFileName{realPath}.GetName();
|
||||
}
|
||||
|
||||
if (mVstVersion >= 2)
|
||||
|
@ -3481,10 +3480,11 @@ bool VSTEffect::LoadXML(const wxFileName & fn)
|
|||
void VSTEffect::SaveFXB(const wxFileName & fn)
|
||||
{
|
||||
// Create/Open the file
|
||||
wxFFile f(fn.GetFullPath(), wxT("wb"));
|
||||
const wxString fullPath{fn.GetFullPath()};
|
||||
wxFFile f(fullPath, wxT("wb"));
|
||||
if (!f.IsOpened())
|
||||
{
|
||||
wxMessageBox(wxString::Format(_("Could not open file: \"%s\""), fn.GetFullPath().c_str()),
|
||||
wxMessageBox(wxString::Format(_("Could not open file: \"%s\""), fullPath.c_str()),
|
||||
_("Error Saving VST Presets"),
|
||||
wxOK | wxCENTRE,
|
||||
mParent);
|
||||
|
@ -3551,7 +3551,7 @@ void VSTEffect::SaveFXB(const wxFileName & fn)
|
|||
|
||||
if (f.Error())
|
||||
{
|
||||
wxMessageBox(wxString::Format(_("Error writing to file: \"%s\""), fn.GetFullPath().c_str()),
|
||||
wxMessageBox(wxString::Format(_("Error writing to file: \"%s\""), fullPath.c_str()),
|
||||
_("Error Saving VST Presets"),
|
||||
wxOK | wxCENTRE,
|
||||
mParent);
|
||||
|
@ -3565,10 +3565,11 @@ void VSTEffect::SaveFXB(const wxFileName & fn)
|
|||
void VSTEffect::SaveFXP(const wxFileName & fn)
|
||||
{
|
||||
// Create/Open the file
|
||||
wxFFile f(fn.GetFullPath(), wxT("wb"));
|
||||
const wxString fullPath{ fn.GetFullPath() };
|
||||
wxFFile f(fullPath, wxT("wb"));
|
||||
if (!f.IsOpened())
|
||||
{
|
||||
wxMessageBox(wxString::Format(_("Could not open file: \"%s\""), fn.GetFullPath().c_str()),
|
||||
wxMessageBox(wxString::Format(_("Could not open file: \"%s\""), fullPath.c_str()),
|
||||
_("Error Saving VST Presets"),
|
||||
wxOK | wxCENTRE,
|
||||
mParent);
|
||||
|
@ -3583,7 +3584,7 @@ void VSTEffect::SaveFXP(const wxFileName & fn)
|
|||
f.Write(buf.GetData(), buf.GetDataLen());
|
||||
if (f.Error())
|
||||
{
|
||||
wxMessageBox(wxString::Format(_("Error writing to file: \"%s\""), fn.GetFullPath().c_str()),
|
||||
wxMessageBox(wxString::Format(_("Error writing to file: \"%s\""), fullPath.c_str()),
|
||||
_("Error Saving VST Presets"),
|
||||
wxOK | wxCENTRE,
|
||||
mParent);
|
||||
|
|
|
@ -206,8 +206,8 @@ bool LadspaEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxSt
|
|||
{
|
||||
// Since we now have builtin VST support, ignore the VST bridge as it
|
||||
// causes duplicate menu entries to appear.
|
||||
wxFileName f(path);
|
||||
if (f.GetName().CmpNoCase(wxT("vst-bridge")) == 0) {
|
||||
wxFileName ff(path);
|
||||
if (ff.GetName().CmpNoCase(wxT("vst-bridge")) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -216,9 +216,9 @@ bool LadspaEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxSt
|
|||
// directory to be the plug-in's directory.
|
||||
wxString envpath;
|
||||
bool hadpath = wxGetEnv(wxT("PATH"), &envpath);
|
||||
wxSetEnv(wxT("PATH"), f.GetPath() + wxFILE_SEP_PATH + envpath);
|
||||
wxString saveOldCWD = f.GetCwd();
|
||||
f.SetCwd();
|
||||
wxSetEnv(wxT("PATH"), ff.GetPath() + wxFILE_SEP_PATH + envpath);
|
||||
wxString saveOldCWD = ff.GetCwd();
|
||||
ff.SetCwd();
|
||||
|
||||
int index = 0;
|
||||
LADSPA_Descriptor_Function mainFn = NULL;
|
||||
|
@ -1572,12 +1572,12 @@ bool LadspaEffect::Load()
|
|||
return true;
|
||||
}
|
||||
|
||||
wxFileName f = mPath;
|
||||
wxFileName ff = mPath;
|
||||
wxString envpath;
|
||||
bool hadpath = wxGetEnv(wxT("PATH"), &envpath);
|
||||
wxSetEnv(wxT("PATH"), f.GetPath() + wxFILE_SEP_PATH + envpath);
|
||||
wxString saveOldCWD = f.GetCwd();
|
||||
f.SetCwd();
|
||||
wxSetEnv(wxT("PATH"), ff.GetPath() + wxFILE_SEP_PATH + envpath);
|
||||
wxString saveOldCWD = ff.GetCwd();
|
||||
ff.SetCwd();
|
||||
|
||||
LADSPA_Descriptor_Function mainFn = NULL;
|
||||
|
||||
|
|
|
@ -152,8 +152,8 @@ NyquistEffect::NyquistEffect(const wxString &fName)
|
|||
return;
|
||||
}
|
||||
|
||||
mName = wxFileName(fName).GetName();
|
||||
mFileName = wxFileName(fName);
|
||||
mFileName = fName;
|
||||
mName = mFileName.GetName();
|
||||
mFileModified = mFileName.GetModificationTime();
|
||||
ParseFile();
|
||||
}
|
||||
|
|
|
@ -204,10 +204,11 @@ bool DirectoriesPrefs::Validate()
|
|||
wxFileName tempDir;
|
||||
tempDir.SetPath(mTempDir->GetValue());
|
||||
|
||||
if( !AudacityApp::IsTempDirectoryNameOK( tempDir.GetPath() ) ) {
|
||||
wxString path{tempDir.GetPath()};
|
||||
if( !AudacityApp::IsTempDirectoryNameOK( path ) ) {
|
||||
wxMessageBox(
|
||||
wxString::Format(_("Directory %s is not suitable (at risk of being cleaned out)"),
|
||||
tempDir.GetPath().c_str()),
|
||||
path.c_str()),
|
||||
_("Error"),
|
||||
wxOK | wxICON_ERROR);
|
||||
return false;
|
||||
|
@ -215,7 +216,7 @@ bool DirectoriesPrefs::Validate()
|
|||
if (!tempDir.DirExists()) {
|
||||
int ans = wxMessageBox(
|
||||
wxString::Format(_("Directory %s does not exist. Create it?"),
|
||||
tempDir.GetPath().c_str()),
|
||||
path.c_str()),
|
||||
_("New Temporary Directory"),
|
||||
wxYES_NO | wxCENTRE | wxICON_EXCLAMATION);
|
||||
|
||||
|
@ -232,10 +233,11 @@ bool DirectoriesPrefs::Validate()
|
|||
/* If the directory already exists, make sure it is writable */
|
||||
wxLogNull logNo;
|
||||
tempDir.AppendDir(wxT("canicreate"));
|
||||
path = tempDir.GetPath();
|
||||
if (!tempDir.Mkdir(0755)) {
|
||||
wxMessageBox(
|
||||
wxString::Format(_("Directory %s is not writable"),
|
||||
tempDir.GetPath().c_str()),
|
||||
path.c_str()),
|
||||
_("Error"),
|
||||
wxOK | wxICON_ERROR);
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue