Windows execute process fix. 71/226971/6
authorVictor Cebollada <v.cebollada@samsung.com>
Wed, 4 Mar 2020 09:00:56 +0000 (09:00 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Tue, 14 Apr 2020 09:42:42 +0000 (10:42 +0100)
* 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>
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;