Merge branch 'export-dialog' into cairocanvas
[ardour.git] / libs / ardour / system_exec.cc
1 /*
2     Copyright (C) 2010 Paul Davis
3     Copyright (C) 2010-2014 Robin Gareus <robin@gareus.org>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #include <glibmm/miscutils.h>
22 #include "pbd/pathscanner.h"
23 #include "pbd/file_utils.h"
24 #include "pbd/error.h"
25
26 #include "ardour/filesystem_paths.h"
27 #include "ardour/system_exec.h"
28
29 using namespace ARDOUR;
30
31 char * SystemExec::_vfork_exec_wrapper = NULL;
32
33 static char *vfork_exec_wrapper_path() {
34 #ifdef PLATFORM_WINDOWS
35         return NULL;
36 #else
37         std::string vfork_exec_wrapper;
38         if (!PBD::find_file_in_search_path (
39                                 PBD::Searchpath(Glib::build_filename(ARDOUR::ardour_dll_directory(), "vfork")),
40                                 "ardour-exec-wrapper", vfork_exec_wrapper)) {
41                 PBD::warning << "vfork exec wrapper not found..'" << endmsg;
42                 return NULL;
43         }
44         return strdup(vfork_exec_wrapper.c_str());
45 #endif
46 }
47
48 SystemExec::SystemExec (std::string c, char ** a)
49         : PBD::SystemExec(c, a)
50 {
51 #ifndef PLATFORM_WINDOWS
52         if (!_vfork_exec_wrapper) {
53                 _vfork_exec_wrapper = vfork_exec_wrapper_path();
54         }
55 #endif
56 }
57
58 SystemExec::SystemExec (std::string c, std::string a)
59         : PBD::SystemExec(c, a)
60 {
61 #ifndef PLATFORM_WINDOWS
62         if (!_vfork_exec_wrapper) {
63                 _vfork_exec_wrapper = vfork_exec_wrapper_path();
64         }
65 #endif
66 }
67
68 SystemExec::SystemExec (std::string c, const std::map<char, std::string> subs)
69         : PBD::SystemExec(c, subs)
70 {
71 #ifndef PLATFORM_WINDOWS
72         if (!_vfork_exec_wrapper) {
73                 _vfork_exec_wrapper = vfork_exec_wrapper_path();
74         }
75 #endif
76 }
77
78 SystemExec::~SystemExec() { }