OpenClonk
PlatformAbstraction.h File Reference
#include <vector>
#include <cstdint>
#include <strings.h>
#include <dirent.h>
#include <limits.h>
#include <fcntl.h>
Include dependency graph for PlatformAbstraction.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEPRECATED
 
#define GNUC_FORMAT_ATTRIBUTE
 
#define GNUC_FORMAT_ATTRIBUTE_O
 
#define ALWAYS_INLINE   inline
 
#define NORETURN
 
#define BREAKPOINT_HERE   ((void)0)
 
#define C4_OS   ""
 
#define _O_BINARY   0
 
#define _MAX_PATH   PATH_MAX
 
#define _MAX_FNAME   NAME_MAX
 
#define _MAX_PATH_LEN   _MAX_PATH + 1
 
#define _MAX_FNAME_LEN   _MAX_FNAME + 1
 
#define O_CLOEXEC   0
 
#define DirSep   "/"
 
#define DirectorySeparator   '/'
 
#define AltDirectorySeparator   '\\'
 

Typedefs

typedef ptrdiff_t ssize_t
 
typedef uint32_t DWORD
 
typedef uint8_t BYTE
 
typedef uint16_t WORD
 

Functions

int stricmp (const char *s1, const char *s2)
 
bool EraseItemSafe (const char *szFilename)
 
bool IsGermanSystem ()
 
bool OpenURL (const char *szURL)
 
bool RestartApplication (std::vector< const char * > parameters)
 
bool CopyFile (const char *szSource, const char *szTarget, bool FailIfExists)
 

Macro Definition Documentation

◆ _MAX_FNAME

#define _MAX_FNAME   NAME_MAX

Definition at line 184 of file PlatformAbstraction.h.

◆ _MAX_FNAME_LEN

#define _MAX_FNAME_LEN   _MAX_FNAME + 1

Definition at line 189 of file PlatformAbstraction.h.

◆ _MAX_PATH

#define _MAX_PATH   PATH_MAX

Definition at line 183 of file PlatformAbstraction.h.

◆ _MAX_PATH_LEN

#define _MAX_PATH_LEN   _MAX_PATH + 1

Definition at line 188 of file PlatformAbstraction.h.

◆ _O_BINARY

#define _O_BINARY   0

Definition at line 182 of file PlatformAbstraction.h.

◆ AltDirectorySeparator

#define AltDirectorySeparator   '\\'

Definition at line 203 of file PlatformAbstraction.h.

◆ ALWAYS_INLINE

#define ALWAYS_INLINE   inline

Definition at line 101 of file PlatformAbstraction.h.

◆ BREAKPOINT_HERE

#define BREAKPOINT_HERE   ((void)0)

Definition at line 120 of file PlatformAbstraction.h.

◆ C4_OS

#define C4_OS   ""

Definition at line 161 of file PlatformAbstraction.h.

◆ DEPRECATED

#define DEPRECATED

Definition at line 62 of file PlatformAbstraction.h.

◆ DirectorySeparator

#define DirectorySeparator   '/'

Definition at line 202 of file PlatformAbstraction.h.

◆ DirSep

#define DirSep   "/"

Definition at line 201 of file PlatformAbstraction.h.

◆ GNUC_FORMAT_ATTRIBUTE

#define GNUC_FORMAT_ATTRIBUTE

Definition at line 99 of file PlatformAbstraction.h.

◆ GNUC_FORMAT_ATTRIBUTE_O

#define GNUC_FORMAT_ATTRIBUTE_O

Definition at line 100 of file PlatformAbstraction.h.

◆ NORETURN

#define NORETURN

Definition at line 102 of file PlatformAbstraction.h.

◆ O_CLOEXEC

#define O_CLOEXEC   0

Definition at line 193 of file PlatformAbstraction.h.

Typedef Documentation

◆ BYTE

typedef uint8_t BYTE

Definition at line 135 of file PlatformAbstraction.h.

◆ DWORD

typedef uint32_t DWORD

Definition at line 134 of file PlatformAbstraction.h.

◆ ssize_t

typedef ptrdiff_t ssize_t

Definition at line 84 of file PlatformAbstraction.h.

◆ WORD

typedef uint16_t WORD

Definition at line 136 of file PlatformAbstraction.h.

Function Documentation

◆ CopyFile()

bool CopyFile ( const char *  szSource,
const char *  szTarget,
bool  FailIfExists 
)

Referenced by CopyItem().

Here is the caller graph for this function:

◆ EraseItemSafe()

bool EraseItemSafe ( const char *  szFilename)

Definition at line 42 of file C4GroupMain.cpp.

43 {
44  return false;
45 }

Referenced by C4Group_DeleteItem(), and C4Group::DeleteEntry().

Here is the caller graph for this function:

◆ IsGermanSystem()

bool IsGermanSystem ( )

Definition at line 193 of file C4AppMac.mm.

194 {
195  id languages = [[NSUserDefaults standardUserDefaults] valueForKey:@"AppleLanguages"];
196  return languages && [[languages objectAtIndex:0] isEqualToString:@"de"];
197 }

Referenced by C4ConfigGeneral::DefaultLanguage().

Here is the caller graph for this function:

◆ OpenURL()

bool OpenURL ( const char *  szURL)

Definition at line 199 of file C4AppMac.mm.

200 {
201  std::string command = std::string("open ") + '"' + szURL + '"';
202  std::system(command.c_str());
203  return true;
204 }

◆ 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:

◆ stricmp()

int stricmp ( const char *  s1,
const char *  s2 
)
inline

Definition at line 139 of file PlatformAbstraction.h.

140 {
141  return strcasecmp(s1, s2);
142 }

Referenced by EntrySortFunc(), C4MainStat::Show(), C4Group::Sort(), and C4ChatControl::ChatSheet::NickItem::SortFunc().

Here is the caller graph for this function: