From 6cdc7fb9003d0d971424c005d774e346cdb38977 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 15 Dec 2015 14:06:49 +0100 Subject: [PATCH] Fixed: Implement launch of executables under OS X --- code/nel/src/misc/common.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 03bd6c3d0..3a8f5e85c 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -728,7 +728,30 @@ bool launchProgram(const std::string &programName, const std::string &arguments, CloseHandle( pi.hThread ); } -#elif defined(NL_OS_UNIX) +#elif defined(NL_OS_MAC) + std::string command; + + if (CFile::getExtension(programName) == "app") + { + // we need to open bundles with "open" command + command = NLMISC::toString("open \"%s\"", programName.c_str()); + } + else + { + command = programName; + } + + // append arguments if any + if (!arguments.empty()) + { + command += NLMISC::toString(" --args %s", arguments.c_str()); + } + + int res = system(command.c_str()); + + if (res && log) + nlwarning ("LAUNCH: Failed launched '%s' with arg '%s' return code %d", programName.c_str(), arguments.c_str(), res); +#else static bool firstLaunchProgram = true; if (firstLaunchProgram) @@ -811,9 +834,6 @@ bool launchProgram(const std::string &programName, const std::string &arguments, return true; } -#else - if (log) - nlwarning ("LAUNCH: launchProgram() not implemented"); #endif return false;