20 #if defined(_X11) || defined(__APPLE__)
22 #include <sys/types.h>
31 #define WIN32_LEAN_AND_MEAN
39 #define ERR_DU LOG_STREAM(err, log_desktop)
40 #define LOG_DU LOG_STREAM(info, log_desktop)
46 #if defined(_X11) || defined(__APPLE__) || defined(_WIN32)
55 LOG_DU <<
"open_object(): requested object: " << path_or_url <<
'\n';
57 #if defined(_X11) || defined(__APPLE__)
60 LOG_DU <<
"open_object(): on X11, will use xdg-open\n";
61 const char launcher[] =
"xdg-open";
63 LOG_DU <<
"open_object(): on OS X, will use open\n";
64 const char launcher[] =
"open";
68 const pid_t child = fork();
71 ERR_DU <<
"open_object(): fork() failed" << std::endl;
73 }
else if(child == 0) {
74 execlp(launcher, launcher, path_or_url.c_str(),
nullptr);
76 }
else if(waitpid(child, &child_status, 0) == -1) {
77 ERR_DU <<
"open_object(): waitpid() failed" << std::endl;
83 #pragma GCC diagnostic push
84 #pragma GCC diagnostic ignored "-Wold-style-cast"
85 if(WIFEXITED(child_status)) {
86 ERR_DU <<
"open_object(): " << launcher <<
" returned "
87 << WEXITSTATUS(child_status) <<
'\n';
88 #pragma GCC diagnostic pop
90 ERR_DU <<
"open_object(): " << launcher <<
" failed" << std::endl;
100 LOG_DU <<
"open_object(): on Win32, will use ShellExecute()\n";
102 std::wstring u16path =
unicode_cast<std::wstring>(path_or_url);
104 const ptrdiff_t
res =
reinterpret_cast<ptrdiff_t
>(ShellExecute(
nullptr, L
"open", u16path.c_str(),
nullptr,
nullptr, SW_SHOW));
106 ERR_DU <<
"open_object(): ShellExecute() failed (" << res <<
")" << std::endl;
115 ERR_DU <<
"open_object(): unsupported platform" << std::endl;
ucs4_convert_impl::enableif< TD, typename TS::value_type >::type unicode_cast(const TS &source)
Desktop environment interaction functions.
bool open_object(const std::string &path_or_url)
Opens the specified object with the default application configured for its type.
bool open_object_is_supported()
Returns whether open_object() is supported/implemented for the current platform.
Standard logging facilities (interface).
GLsizei const GLcharARB ** string
static lg::log_domain log_desktop("desktop")