2 * Copyright (C) 2018 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 /* This extends ardour/filesystem_paths.cc but requires additional
20 * includes, in particular 'rc_configuration.h' which in turn
21 * pulls in types.h, which include temporal/bbt_time and evoral
23 * filesystem_paths.cc is used by various standalone utils,
24 * e.g. the VST scanner and pulling in most of libardour's dependencies
25 * there is not reasonable.
30 #include "pbd/file_utils.h"
32 #include <glibmm/convert.h>
33 #include <glibmm/miscutils.h>
34 #include <glibmm/fileutils.h>
36 #include "ardour/filesystem_paths.h"
37 #include "ardour/rc_configuration.h"
41 #ifdef PLATFORM_WINDOWS
44 #include "pbd/windows_special_dirs.h"
51 #ifdef PLATFORM_WINDOWS
53 windows_install_dir (const char *regkey, std::string &rv) {
55 DWORD size = PATH_MAX;
58 if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ, &key))
59 && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
62 rv = Glib::locale_to_utf8(tmp);
66 if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ | KEY_WOW64_32KEY, &key))
67 && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
70 rv = Glib::locale_to_utf8(tmp);
79 ArdourVideoToolPaths::harvid_exe (std::string &harvid_exe)
82 #ifdef PLATFORM_WINDOWS
84 std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
89 std::string icsd_file_path;
90 if (find_file (PBD::Searchpath(Glib::getenv("PATH")), X_("harvid"), icsd_file_path)) {
91 harvid_exe = icsd_file_path;
93 #ifdef PLATFORM_WINDOWS
94 else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
96 harvid_exe = g_build_filename(reg.c_str(), "harvid", "harvid.exe", NULL);
98 else if ( windows_install_dir("Software\\RSS\\harvid", reg))
100 harvid_exe = g_build_filename(reg.c_str(), "harvid.exe", NULL);
102 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "harvid", "harvid.exe", NULL), Glib::FILE_TEST_EXISTS))
104 harvid_exe = g_build_filename(program_files.c_str(), "harvid", "harvid.exe", NULL);
106 else if (Glib::file_test(X_("C:\\Program Files\\harvid\\harvid.exe"), Glib::FILE_TEST_EXISTS)) {
107 harvid_exe = X_("C:\\Program Files\\harvid\\harvid.exe");
118 ArdourVideoToolPaths::xjadeo_exe (std::string &xjadeo_exe)
120 std::string xjadeo_file_path;
121 #ifdef PLATFORM_WINDOWS
123 std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
127 if (getenv("XJREMOTE")) {
128 xjadeo_exe = getenv("XJREMOTE");
130 } else if (!Config->get_xjadeo_binary().empty()
131 && Glib::file_test (Config->get_xjadeo_binary() + "/Contents/MacOS/xjadeo", Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
132 xjadeo_exe = Config->get_xjadeo_binary() + "/Contents/MacOS/xjadeo";
134 } else if (!Config->get_xjadeo_binary().empty()
135 && Glib::file_test (Config->get_xjadeo_binary(), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
136 xjadeo_exe = Config->get_xjadeo_binary();
137 } else if (find_file (Searchpath(Glib::getenv("PATH")), X_("xjremote"), xjadeo_file_path)) {
138 xjadeo_exe = xjadeo_file_path;
139 } else if (find_file (Searchpath(Glib::getenv("PATH")), X_("xjadeo"), xjadeo_file_path)) {
140 xjadeo_exe = xjadeo_file_path;
143 else if (Glib::file_test(X_("/Applications/Xjadeo.app/Contents/MacOS/xjadeo"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
144 xjadeo_exe = X_("/Applications/Xjadeo.app/Contents/MacOS/xjadeo");
146 else if (Glib::file_test(X_("/Applications/Jadeo.app/Contents/MacOS/Jadeo-bin"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
147 xjadeo_exe = X_("/Applications/Jadeo.app/Contents/MacOS/Jadeo-bin");
150 #ifdef PLATFORM_WINDOWS
151 else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
153 xjadeo_exe = std::string(g_build_filename(reg.c_str(), "xjadeo", "xjadeo.exe", NULL));
155 else if ( windows_install_dir("Software\\RSS\\xjadeo", reg))
157 xjadeo_exe = std::string(g_build_filename(reg.c_str(), "xjadeo.exe", NULL));
159 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "xjadeo", "xjadeo.exe", NULL), Glib::FILE_TEST_EXISTS))
161 xjadeo_exe = std::string(g_build_filename(program_files.c_str(), "xjadeo", "xjadeo.exe", NULL));
163 else if (Glib::file_test(X_("C:\\Program Files\\xjadeo\\xjadeo.exe"), Glib::FILE_TEST_EXISTS)) {
164 xjadeo_exe = X_("C:\\Program Files\\xjadeo\\xjadeo.exe");
168 return (!xjadeo_exe.empty() && Glib::file_test(xjadeo_exe, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE));
172 ArdourVideoToolPaths::transcoder_exe (std::string &ffmpeg_exe, std::string &ffprobe_exe)
174 #ifdef PLATFORM_WINDOWS
176 std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
180 ffprobe_exe = X_("");
182 std::string ff_file_path;
183 if (find_file (Searchpath(Glib::getenv("PATH")), X_("ffmpeg_harvid"), ff_file_path)) {
184 ffmpeg_exe = ff_file_path;
186 #ifdef PLATFORM_WINDOWS
187 else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
189 ffmpeg_exe = g_build_filename(reg.c_str(), X_("harvid"), X_("ffmpeg.exe"), NULL);
190 ffprobe_exe = g_build_filename(reg.c_str(), X_("harvid"), X_("ffprobe.exe"), NULL);
192 else if ( windows_install_dir("Software\\RSS\\harvid", reg))
194 ffmpeg_exe = g_build_filename(reg.c_str(), X_("ffmpeg.exe"), NULL);
195 ffprobe_exe = g_build_filename(reg.c_str(), X_("ffprobe.exe"), NULL);
198 if (Glib::file_test(ffmpeg_exe, Glib::FILE_TEST_EXISTS)) {
201 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "harvid", "ffmpeg.exe", NULL), Glib::FILE_TEST_EXISTS)) {
202 ffmpeg_exe = g_build_filename(program_files.c_str(), "harvid", "ffmpeg.exe", NULL);
204 else if (Glib::file_test(X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe"), Glib::FILE_TEST_EXISTS)) {
205 ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe");
211 if (find_file (Searchpath(Glib::getenv("PATH")), X_("ffprobe_harvid"), ff_file_path)) {
212 ffprobe_exe = ff_file_path;
214 #ifdef PLATFORM_WINDOWS
215 if (Glib::file_test(ffprobe_exe, Glib::FILE_TEST_EXISTS)) {
218 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "harvid", "ffprobe.exe", NULL), Glib::FILE_TEST_EXISTS)) {
219 ffprobe_exe = g_build_filename(program_files.c_str(), "harvid", "ffprobe.exe", NULL);
221 else if (Glib::file_test(X_("C:\\Program Files\\ffmpeg\\ffprobe.exe"), Glib::FILE_TEST_EXISTS)) {
222 ffprobe_exe = X_("C:\\Program Files\\ffmpeg\\ffprobe.exe");
224 ffprobe_exe = X_("");
228 if (ffmpeg_exe.empty() || ffprobe_exe.empty()) {
234 } // namespace ARDOUR