mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-26 09:08:44 +02:00
Get the Windows specific search working for external command exporting
This commit is contained in:
parent
8ef0bf3392
commit
f449607751
@ -306,6 +306,47 @@ private:
|
|||||||
std::vector<char> GetMetaChunk(const Tags *metadata);
|
std::vector<char> GetMetaChunk(const Tags *metadata);
|
||||||
wxString mCmd;
|
wxString mCmd;
|
||||||
bool mShow;
|
bool mShow;
|
||||||
|
|
||||||
|
struct ExtendPath
|
||||||
|
{
|
||||||
|
#if defined(__WXMSW__)
|
||||||
|
wxString opath;
|
||||||
|
|
||||||
|
ExtendPath()
|
||||||
|
{
|
||||||
|
// Give Windows a chance at finding lame command in the default location.
|
||||||
|
wxString paths[] = {wxT("HKEY_LOCAL_MACHINE\\Software\\Lame for Audacity"),
|
||||||
|
wxT("HKEY_LOCAL_MACHINE\\Software\\FFmpeg for Audacity")};
|
||||||
|
wxString npath;
|
||||||
|
wxRegKey reg;
|
||||||
|
|
||||||
|
wxGetEnv(wxT("PATH"), &opath);
|
||||||
|
npath = opath;
|
||||||
|
|
||||||
|
for (int i = 0; i < WXSIZEOF(paths); i++) {
|
||||||
|
reg.SetName(paths[i]);
|
||||||
|
|
||||||
|
if (reg.Exists()) {
|
||||||
|
wxString ipath;
|
||||||
|
reg.QueryValue(wxT("InstallPath"), ipath);
|
||||||
|
if (!ipath.empty()) {
|
||||||
|
npath += wxPATH_SEP + ipath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSetEnv(wxT("PATH"),npath);
|
||||||
|
};
|
||||||
|
|
||||||
|
~ExtendPath()
|
||||||
|
{
|
||||||
|
if (!opath.empty())
|
||||||
|
{
|
||||||
|
wxSetEnv(wxT("PATH"),opath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
ExportCL::ExportCL()
|
ExportCL::ExportCL()
|
||||||
@ -330,6 +371,7 @@ ProgressResult ExportCL::Export(AudacityProject *project,
|
|||||||
const Tags *metadata,
|
const Tags *metadata,
|
||||||
int WXUNUSED(subformat))
|
int WXUNUSED(subformat))
|
||||||
{
|
{
|
||||||
|
ExtendPath ep;
|
||||||
wxString output;
|
wxString output;
|
||||||
long rc;
|
long rc;
|
||||||
|
|
||||||
@ -344,47 +386,10 @@ ProgressResult ExportCL::Export(AudacityProject *project,
|
|||||||
mCmd.Replace( "%f", "%f.wav" );
|
mCmd.Replace( "%f", "%f.wav" );
|
||||||
mCmd.Replace(wxT("%f"), path);
|
mCmd.Replace(wxT("%f"), path);
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
|
||||||
// Give Windows a chance at finding lame command in the default location.
|
|
||||||
wxString paths[] = {wxT("HKEY_LOCAL_MACHINE\\Software\\Lame for Audacity"),
|
|
||||||
wxT("HKEY_LOCAL_MACHINE\\Software\\FFmpeg for Audacity")};
|
|
||||||
wxString opath;
|
|
||||||
wxString npath;
|
|
||||||
wxRegKey reg;
|
|
||||||
|
|
||||||
wxGetEnv(wxT("PATH"), &opath);
|
|
||||||
npath = opath;
|
|
||||||
|
|
||||||
for (int i = 0; i < WXSIZEOF(paths); i++) {
|
|
||||||
reg.SetName(paths[i]);
|
|
||||||
|
|
||||||
if (reg.Exists()) {
|
|
||||||
wxString ipath;
|
|
||||||
reg.QueryValue(wxT("InstallPath"), ipath);
|
|
||||||
if (!ipath.empty()) {
|
|
||||||
npath += wxPATH_SEP + ipath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSetEnv(wxT("PATH"),npath);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Kick off the command
|
// Kick off the command
|
||||||
ExportCLProcess process(&output);
|
ExportCLProcess process(&output);
|
||||||
|
|
||||||
{
|
rc = wxExecute(mCmd, wxEXEC_ASYNC, &process);
|
||||||
#if defined(__WXMSW__)
|
|
||||||
auto cleanup = finally( [&] {
|
|
||||||
if (!opath.empty()) {
|
|
||||||
wxSetEnv(wxT("PATH"),opath);
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rc = wxExecute(mCmd, wxEXEC_ASYNC, &process);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
AudacityMessageBox( XO("Cannot export audio to %s").Format( path ) );
|
AudacityMessageBox( XO("Cannot export audio to %s").Format( path ) );
|
||||||
process.Detach();
|
process.Detach();
|
||||||
@ -720,11 +725,15 @@ void ExportCL::OptionsCreate(ShuttleGui &S, int format)
|
|||||||
|
|
||||||
bool ExportCL::CheckFileName(wxFileName &filename, int WXUNUSED(format))
|
bool ExportCL::CheckFileName(wxFileName &filename, int WXUNUSED(format))
|
||||||
{
|
{
|
||||||
if (ShowWarningDialog(NULL,
|
ExtendPath ep;
|
||||||
wxT("MissingExtension"),
|
|
||||||
XO("You've specified a file name without an extension. Are you sure?"),
|
if (filename.GetExt().empty()) {
|
||||||
true) == wxID_CANCEL) {
|
if (ShowWarningDialog(NULL,
|
||||||
return false;
|
wxT("MissingExtension"),
|
||||||
|
XO("You've specified a file name without an extension. Are you sure?"),
|
||||||
|
true) == wxID_CANCEL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetSettings();
|
GetSettings();
|
||||||
@ -747,12 +756,19 @@ bool ExportCL::CheckFileName(wxFileName &filename, int WXUNUSED(format))
|
|||||||
|
|
||||||
// Normalize the path (makes absolute and resolves variables)
|
// Normalize the path (makes absolute and resolves variables)
|
||||||
wxFileName cmd(argv[0]);
|
wxFileName cmd(argv[0]);
|
||||||
cmd.Normalize();
|
cmd.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_ABSOLUTE);
|
||||||
|
|
||||||
// Search for the command in the PATH list
|
// Search for the command in the PATH list
|
||||||
wxPathList pathlist;
|
wxPathList pathlist;
|
||||||
pathlist.AddEnvList(wxT("PATH"));
|
pathlist.AddEnvList(wxT("PATH"));
|
||||||
wxString path = pathlist.FindAbsoluteValidPath(cmd.GetFullPath());
|
wxString path = pathlist.FindAbsoluteValidPath(argv[0]);
|
||||||
|
|
||||||
|
#if defined(__WXMSW__)
|
||||||
|
if (path.empty()) {
|
||||||
|
path = pathlist.FindAbsoluteValidPath(argv[0] + wxT(".exe"));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (path.empty()) {
|
if (path.empty()) {
|
||||||
auto prompt = XO("Unable to locate \"%s\" in your path.\n\nWould you like to continue anyway?")
|
auto prompt = XO("Unable to locate \"%s\" in your path.\n\nWould you like to continue anyway?")
|
||||||
.Format(cmd.GetFullPath());
|
.Format(cmd.GetFullPath());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user