From d5388dfb953295cec97dff2966791345e89f84c8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 13 Mar 2005 17:47:27 +0000 Subject: [PATCH] Handle temp paths with spaces. --- ChangeLog | 5 +++++ src/mmg/jobs.cpp | 8 +++++--- src/mmg/mux_dialog.cpp | 4 ++-- src/mmg/tab_input.cpp | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04954b792..6c3111ecc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-03-13 Moritz Bunkus + + * mmg: bug fix: If the TEMP environment variable contains spaces + then the calls to mkvmerge when adding files failed. + 2005-03-06 Moritz Bunkus * mkvmerge: bug fix: Extracting the FPS from some AVC MP4 files diff --git a/src/mmg/jobs.cpp b/src/mmg/jobs.cpp index b7b98662c..0d84ef7cf 100644 --- a/src/mmg/jobs.cpp +++ b/src/mmg/jobs.cpp @@ -155,8 +155,10 @@ job_run_dialog::start_next_job() { mdlg->load(wxString::Format(wxT("%s/jobs/%d.mmg"), wxGetCwd().c_str(), jobs[ndx].id)); - opt_file_name.Printf(wxT("mmg-mkvmerge-options-%d-%d"), + opt_file_name.Printf(wxT("%smmg-mkvmerge-options-%d-%d"), + get_temp_dir().c_str(), (int)wxGetProcessId(), (int)time(NULL)); + try { opt_file = new wxFile(opt_file_name, wxFile::write); } catch (...) { @@ -191,8 +193,8 @@ job_run_dialog::start_next_job() { process = new wxProcess(this, 1); process->Redirect(); - pid = wxExecute((*arg_list)[0] + wxT(" @") + opt_file_name, wxEXEC_ASYNC, - process); + pid = wxExecute((*arg_list)[0] + wxT(" \"@") + opt_file_name + wxT("\""), + wxEXEC_ASYNC, process); out = process->GetInputStream(); *jobs[ndx].log = wxT(""); diff --git a/src/mmg/mux_dialog.cpp b/src/mmg/mux_dialog.cpp index 859f7f8b6..0f3cbc428 100644 --- a/src/mmg/mux_dialog.cpp +++ b/src/mmg/mux_dialog.cpp @@ -144,8 +144,8 @@ mux_dialog::mux_dialog(wxWindow *parent): } delete opt_file; - pid = wxExecute((*arg_list)[0] + wxT(" @") + opt_file_name, wxEXEC_ASYNC, - process); + pid = wxExecute((*arg_list)[0] + wxT(" \"@") + opt_file_name + wxT("\""), + wxEXEC_ASYNC, process); out = process->GetInputStream(); line = ""; diff --git a/src/mmg/tab_input.cpp b/src/mmg/tab_input.cpp index 4ab1c4f09..d488ece83 100644 --- a/src/mmg/tab_input.cpp +++ b/src/mmg/tab_input.cpp @@ -764,7 +764,7 @@ tab_input::add_file(const wxString &file_name, wxUCS(strerror(errno))); wxMessageBox(error, wxT("File creation failed"), wxOK | wxCENTER | wxICON_ERROR); - throw 0; + return; } opt_file->Write(wxT("--output-charset\nUTF-8\n--identify-verbose\n")); arg_utf8 = to_utf8(file_name); @@ -772,8 +772,19 @@ tab_input::add_file(const wxString &file_name, opt_file->Write(wxT("\n")); delete opt_file; - command = wxT("\"") + mkvmerge_path + wxT("\" @") + opt_file_name; + command = wxT("\"") + mkvmerge_path + wxT("\" \"@") + opt_file_name + + wxT("\""); + + wxLogMessage(wxT("identify 1: command: ``%s''"), command.c_str()); + result = wxExecute(command, output, errors); + + wxLogMessage(wxT("identify 1: result: %d"), result); + for (i = 0; i < output.Count(); i++) + wxLogMessage(wxT("identify 1: output[%d]: ``%s''"), i, output[i].c_str()); + for (i = 0; i < errors.Count(); i++) + wxLogMessage(wxT("identify 1: errors[%d]: ``%s''"), i, errors[i].c_str()); + wxRemoveFile(opt_file_name); if ((result < 0) || (result > 1)) { name.Printf(wxT("File identification failed for '%s'. Return code: "