From 62e7c096309f5fb4dc98378f86dad3d80a972fae Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Wed, 4 Mar 2020 09:00:56 +0000 Subject: [PATCH] Windows execute process fix. * The path set on the DEMO_EXAMPLE_BIN macro can be absolute or relative depending on the build system (cmake, vs project, etc). Change-Id: I802530cbf5109b2b6db962c8e3801a74f7b86a4a Signed-off-by: Victor Cebollada --- shared/execute-process-win.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/shared/execute-process-win.cpp b/shared/execute-process-win.cpp index 8445221..4bbc672 100644 --- a/shared/execute-process-win.cpp +++ b/shared/execute-process-win.cpp @@ -29,17 +29,26 @@ const std::string PATH_SEPARATOR( "\\" ); void ExecuteProcess( const std::string& processName, Dali::Application& application ) { - char currentPath[MAX_PATH]; - DWORD numberOfCharacters = GetCurrentDirectory( MAX_PATH, currentPath ); + std::string processPathName; - if( 0u == numberOfCharacters ) + const bool isRelativePath = '.' == DEMO_EXAMPLE_BIN[0]; + if (isRelativePath) { - DALI_ASSERT_ALWAYS( !"Failed to retrieve the current working directory" ); - } + char currentPath[MAX_PATH]; + DWORD numberOfCharacters = GetCurrentDirectory( MAX_PATH, currentPath ); - currentPath[numberOfCharacters] = '\0'; + if( 0u == numberOfCharacters ) + { + DALI_ASSERT_ALWAYS( !"Failed to retrieve the current working directory" ); + } - const std::string processPathName = std::string( currentPath ) + PATH_SEPARATOR + DEMO_EXAMPLE_BIN + PATH_SEPARATOR + processName + ".exe"; + currentPath[numberOfCharacters] = '\0'; + processPathName = std::string(currentPath) + PATH_SEPARATOR + DEMO_EXAMPLE_BIN + PATH_SEPARATOR + processName + ".exe"; + } + else + { + processPathName = DEMO_EXAMPLE_BIN + PATH_SEPARATOR + processName + ".exe"; + } STARTUPINFO info = { sizeof( info ) }; PROCESS_INFORMATION processInfo; -- 2.7.4