OpenClonk
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

◆ EraseItemSafe()

bool EraseItemSafe ( const char *  szFilename)

Definition at line 62 of file PlatformAbstraction.cpp.

63 {
64  return false;
65 }

◆ IsGermanSystem()

bool IsGermanSystem ( )

Definition at line 54 of file PlatformAbstraction.cpp.

55 {
56  if (strstr(setlocale(LC_MESSAGES, nullptr), "de"))
57  return true;
58  else
59  return false;
60 }

◆ OpenURL()

bool OpenURL ( char const *  szURL)

Definition at line 75 of file PlatformAbstraction.cpp.

75 {return 0;}

◆ RestartApplication()

bool RestartApplication ( std::vector< const char * >  parameters)

Definition at line 81 of file PlatformAbstraction.cpp.

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

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

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

Here is the call graph for this function:
Here is the caller graph for this function: