Windows execute process fix. 58/230958/1
authorVictor Cebollada <v.cebollada@samsung.com>
Wed, 4 Mar 2020 09:00:56 +0000 (09:00 +0000)
committerVíctor Cebollada <v.cebollada@samsung.com>
Thu, 16 Apr 2020 07:54:13 +0000 (07:54 +0000)
* 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 <v.cebollada@samsung.com>
(cherry picked from commit 62e7c096309f5fb4dc98378f86dad3d80a972fae)

shared/execute-process-win.cpp

index 8445221..4bbc672 100644 (file)
@@ -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;