OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
PlatformAbstraction.cpp File Reference
#include "C4Include.h"
#include "game/C4Application.h"
Include dependency graph for PlatformAbstraction.cpp:

Go to the source code of this file.

Functions

bool IsGermanSystem ()
 
bool EraseItemSafe (const char *szFilename)
 
bool OpenURL (char const *)
 
bool RestartApplication (std::vector< const char * > parameters)
 

Function Documentation

bool EraseItemSafe ( const char *  szFilename)

Definition at line 62 of file PlatformAbstraction.cpp.

63 {
64  return false;
65 }
bool IsGermanSystem ( )

Definition at line 54 of file PlatformAbstraction.cpp.

55 {
56  if (strstr(setlocale(LC_MESSAGES, 0), "de"))
57  return true;
58  else
59  return false;
60 }
bool OpenURL ( char const *  )

Definition at line 76 of file PlatformAbstraction.cpp.

76 {return 0;}
bool RestartApplication ( std::vector< const char * >  parameters)

Definition at line 82 of file PlatformAbstraction.cpp.

References _MAX_PATH, Application, Config, C4ConfigGeneral::ExePath, C4Config::General, and C4Application::Quit().

Referenced by C4StartupNetDlg::DoOK(), and C4StartupMainDlg::OnEditorBtn().

83 {
84  // restart with given parameters
85  bool success = false;
86 #ifdef _WIN32
87  wchar_t buf[_MAX_PATH];
88  DWORD sz = ::GetModuleFileName(::GetModuleHandle(nullptr), buf, _MAX_PATH);
89  if (sz)
90  {
91  StdStrBuf params;
92  for (auto p : parameters)
93  {
94  params += "\"";
95  params += p;
96  params += "\" ";
97  }
98  intptr_t iError = (intptr_t)::ShellExecute(nullptr, nullptr, buf, params.GetWideChar(), Config.General.ExePath.GetWideChar(), SW_SHOW);
99  if (iError > 32) success = true;
100  }
101 #else
102  pid_t pid;
103  switch (pid = fork())
104  {
105  case -1: break; // error message shown below
106  case 0:
107  {
108  std::vector<const char*> params = {"openclonk"};
109  params.insert(params.end(), parameters.begin(), parameters.end());
110  params.push_back(nullptr);
111  execv("/proc/self/exe", const_cast<char *const *>(params.data()));
112  perror("editor launch failed");
113  exit(1);
114  }
115  default:
116  success = true;
117  }
118 #endif
119  // must quit ourselves for new instance to be shown
120  if (success) Application.Quit();
121  return success;
122 }
C4Config Config
Definition: C4Config.cpp:837
C4ConfigGeneral General
Definition: C4Config.h:252
#define _MAX_PATH
virtual void Quit()
StdCopyStrBuf ExePath
Definition: C4Config.h:53
uint32_t DWORD
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function: