Updated demos to use DALi clang-format
[platform/core/uifw/dali-demo.git] / shared / execute-process-win.cpp
index 8445221..64a4a0a 100644 (file)
  *
  */
 
- // FILE HEADER
+// FILE HEADER
 #include "execute-process.h"
 
- // EXTERNAL INCLUDES
-#include <windows.h>
+// EXTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
+#include <windows.h>
 
 namespace
 {
-const std::string PATH_SEPARATOR( "\\" );
+const std::string PATH_SEPARATOR("\\");
 }
 
-void ExecuteProcess( const std::string& processName, Dali::Application& application )
+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 ) };
+  STARTUPINFO         info = {sizeof(info)};
   PROCESS_INFORMATION processInfo;
-  if( CreateProcess( processPathName.c_str(), nullptr, nullptr, nullptr, TRUE, 0, nullptr, nullptr, &info, &processInfo ) )
+  if(CreateProcess(processPathName.c_str(), nullptr, nullptr, nullptr, TRUE, 0, nullptr, nullptr, &info, &processInfo))
   {
-    WaitForSingleObject( processInfo.hProcess, INFINITE );
-    CloseHandle( processInfo.hProcess );
-    CloseHandle( processInfo.hThread );
+    WaitForSingleObject(processInfo.hProcess, INFINITE);
+    CloseHandle(processInfo.hProcess);
+    CloseHandle(processInfo.hThread);
   }
 }