fix/silence various compiler warnings.
[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/file_utils.h"
23 #include "pbd/error.h"
24
25 #include "ardour/filesystem_paths.h"
26 #include "ardour/system_exec.h"
27
28 using namespace ARDOUR;
29
30 #ifndef PLATFORM_WINDOWS
31 char * SystemExec::_vfork_exec_wrapper = NULL;
32 #endif
33
34 static char *vfork_exec_wrapper_path() {
35 #ifdef PLATFORM_WINDOWS
36         return NULL;
37 #else
38         std::string vfork_exec_wrapper;
39         if (!PBD::find_file (
40                                 PBD::Searchpath(
41                                         ARDOUR::ardour_dll_directory() // deployed
42                                         + G_SEARCHPATH_SEPARATOR_S + Glib::build_filename(ARDOUR::ardour_dll_directory(), "vfork") // src, build (ardev, etc)
43                                         ),
44                                 "ardour-exec-wrapper", vfork_exec_wrapper)) {
45                 PBD::fatal << "vfork exec wrapper 'ardour-exec-wrapper' was not found in $PATH." << endmsg;
46                 /* not reached */
47                 return NULL;
48         }
49         return strdup(vfork_exec_wrapper.c_str());
50 #endif
51 }
52
53 SystemExec::SystemExec (std::string c, char ** a)
54         : PBD::SystemExec(c, a)
55 {
56 #ifndef PLATFORM_WINDOWS
57         if (!_vfork_exec_wrapper) {
58                 _vfork_exec_wrapper = vfork_exec_wrapper_path();
59         }
60 #endif
61 }
62
63 SystemExec::SystemExec (std::string c, std::string a)
64         : PBD::SystemExec(c, a)
65 {
66 #ifndef PLATFORM_WINDOWS
67         if (!_vfork_exec_wrapper) {
68                 _vfork_exec_wrapper = vfork_exec_wrapper_path();
69         }
70 #endif
71 }
72
73 SystemExec::SystemExec (std::string c, const std::map<char, std::string> subs)
74         : PBD::SystemExec(c, subs)
75 {
76 #ifndef PLATFORM_WINDOWS
77         if (!_vfork_exec_wrapper) {
78                 _vfork_exec_wrapper = vfork_exec_wrapper_path();
79         }
80 #endif
81 }
82
83 SystemExec::~SystemExec() { }