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/miscutils.h>
33 #include <glibmm/fileutils.h>
35 #include "ardour/filesystem_paths.h"
36 #include "ardour/rc_configuration.h"
40 #ifdef PLATFORM_WINDOWS
43 #include "pbd/windows_special_dirs.h"
50 #ifdef PLATFORM_WINDOWS
52 windows_install_dir (const char *regkey, std::string &rv) {
54 DWORD size = PATH_MAX;
57 if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ, &key))
58 && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
61 rv = Glib::locale_to_utf8(tmp);
65 if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ | KEY_WOW64_32KEY, &key))
66 && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
69 rv = Glib::locale_to_utf8(tmp);
78 ArdourVideoToolPaths::harvid_exe (std::string &harvid_exe)
81 #ifdef PLATFORM_WINDOWS
83 std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
88 std::string icsd_file_path;
89 if (find_file (PBD::Searchpath(Glib::getenv("PATH")), X_("harvid"), icsd_file_path)) {
90 harvid_exe = icsd_file_path;
92 #ifdef PLATFORM_WINDOWS
93 else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
95 harvid_exe = g_build_filename(reg.c_str(), "harvid", "harvid.exe", NULL);
97 else if ( windows_install_dir("Software\\RSS\\harvid", reg))
99 harvid_exe = g_build_filename(reg.c_str(), "harvid.exe", NULL);
101 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "harvid", "harvid.exe", NULL), Glib::FILE_TEST_EXISTS))
103 harvid_exe = g_build_filename(program_files.c_str(), "harvid", "harvid.exe", NULL);
105 else if (Glib::file_test(X_("C:\\Program Files\\harvid\\harvid.exe"), Glib::FILE_TEST_EXISTS)) {
106 harvid_exe = X_("C:\\Program Files\\harvid\\harvid.exe");
117 ArdourVideoToolPaths::xjadeo_exe (std::string &xjadeo_exe)
119 std::string xjadeo_file_path;
120 #ifdef PLATFORM_WINDOWS
122 std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
126 if (getenv("XJREMOTE")) {
127 xjadeo_exe = getenv("XJREMOTE");
129 } else if (!Config->get_xjadeo_binary().empty()
130 && Glib::file_test (Config->get_xjadeo_binary() + "/Contents/MacOS/xjadeo", Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
131 xjadeo_exe = Config->get_xjadeo_binary() + "/Contents/MacOS/xjadeo";
133 } else if (!Config->get_xjadeo_binary().empty()
134 && Glib::file_test (Config->get_xjadeo_binary(), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
135 xjadeo_exe = Config->get_xjadeo_binary();
136 } else if (find_file (Searchpath(Glib::getenv("PATH")), X_("xjremote"), xjadeo_file_path)) {
137 xjadeo_exe = xjadeo_file_path;
138 } else if (find_file (Searchpath(Glib::getenv("PATH")), X_("xjadeo"), xjadeo_file_path)) {
139 xjadeo_exe = xjadeo_file_path;
142 else if (Glib::file_test(X_("/Applications/Xjadeo.app/Contents/MacOS/xjadeo"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
143 xjadeo_exe = X_("/Applications/Xjadeo.app/Contents/MacOS/xjadeo");
145 else if (Glib::file_test(X_("/Applications/Jadeo.app/Contents/MacOS/Jadeo-bin"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
146 xjadeo_exe = X_("/Applications/Jadeo.app/Contents/MacOS/Jadeo-bin");
149 #ifdef PLATFORM_WINDOWS
150 else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
152 xjadeo_exe = std::string(g_build_filename(reg.c_str(), "xjadeo", "xjadeo.exe", NULL));
154 else if ( windows_install_dir("Software\\RSS\\xjadeo", reg))
156 xjadeo_exe = std::string(g_build_filename(reg.c_str(), "xjadeo.exe", NULL));
158 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "xjadeo", "xjadeo.exe", NULL), Glib::FILE_TEST_EXISTS))
160 xjadeo_exe = std::string(g_build_filename(program_files.c_str(), "xjadeo", "xjadeo.exe", NULL));
162 else if (Glib::file_test(X_("C:\\Program Files\\xjadeo\\xjadeo.exe"), Glib::FILE_TEST_EXISTS)) {
163 xjadeo_exe = X_("C:\\Program Files\\xjadeo\\xjadeo.exe");
167 return (!xjadeo_exe.empty() && Glib::file_test(xjadeo_exe, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE));
171 ArdourVideoToolPaths::transcoder_exe (std::string &ffmpeg_exe, std::string &ffprobe_exe)
173 #ifdef PLATFORM_WINDOWS
175 std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
179 ffprobe_exe = X_("");
181 std::string ff_file_path;
182 if (find_file (Searchpath(Glib::getenv("PATH")), X_("ffmpeg_harvid"), ff_file_path)) {
183 ffmpeg_exe = ff_file_path;
185 #ifdef PLATFORM_WINDOWS
186 else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
188 ffmpeg_exe = g_build_filename(reg.c_str(), X_("harvid"), X_("ffmpeg.exe"), NULL);
189 ffprobe_exe = g_build_filename(reg.c_str(), X_("harvid"), X_("ffprobe.exe"), NULL);
191 else if ( windows_install_dir("Software\\RSS\\harvid", reg))
193 ffmpeg_exe = g_build_filename(reg.c_str(), X_("ffmpeg.exe"), NULL);
194 ffprobe_exe = g_build_filename(reg.c_str(), X_("ffprobe.exe"), NULL);
197 if (Glib::file_test(ffmpeg_exe, Glib::FILE_TEST_EXISTS)) {
200 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "harvid", "ffmpeg.exe", NULL), Glib::FILE_TEST_EXISTS)) {
201 ffmpeg_exe = g_build_filename(program_files.c_str(), "harvid", "ffmpeg.exe", NULL);
203 else if (Glib::file_test(X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe"), Glib::FILE_TEST_EXISTS)) {
204 ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe");
210 if (find_file (Searchpath(Glib::getenv("PATH")), X_("ffprobe_harvid"), ff_file_path)) {
211 ffprobe_exe = ff_file_path;
213 #ifdef PLATFORM_WINDOWS
214 if (Glib::file_test(ffprobe_exe, Glib::FILE_TEST_EXISTS)) {
217 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "harvid", "ffprobe.exe", NULL), Glib::FILE_TEST_EXISTS)) {
218 ffprobe_exe = g_build_filename(program_files.c_str(), "harvid", "ffprobe.exe", NULL);
220 else if (Glib::file_test(X_("C:\\Program Files\\ffmpeg\\ffprobe.exe"), Glib::FILE_TEST_EXISTS)) {
221 ffprobe_exe = X_("C:\\Program Files\\ffmpeg\\ffprobe.exe");
223 ffprobe_exe = X_("");
227 if (ffmpeg_exe.empty() || ffprobe_exe.empty()) {
233 } // namespace ARDOUR