All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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.


#define ALWAYS_INLINE   inline
#define NORETURN
#define BREAKPOINT_HERE   ((void)0)
#define C4_OS   ""
#define _O_BINARY   0
#define _MAX_PATH   PATH_MAX
#define O_CLOEXEC   0
#define DirSep   "/"
#define DirectorySeparator   '/'
#define AltDirectorySeparator   '\\'


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


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

#define _MAX_PATH   PATH_MAX

Definition at line 183 of file PlatformAbstraction.h.

Referenced by C4MainMenu::ActivateNewPlayer(), C4MainMenu::ActivateSavegame(), CStdFile::Append(), C4Config::AtExePath(), C4Config::AtNetworkPath(), C4Config::AtScreenshotPath(), C4Config::AtSystemDataPath(), C4Config::AtTempPath(), C4Config::AtTempUpdatePath(), C4Config::AtUserDataPath(), C4ClientPlayerInfos::C4ClientPlayerInfos(), C4Group_CopyItem(), C4Group_DeleteItem(), C4Group_IsExcluded(), C4Group_MoveItem(), C4Group_PackDirectory(), C4Group_PackDirectoryTo(), C4Group_ReadFile(), C4Group_SetTempPath(), C4Group_UnpackDirectory(), C4PortraitSelDlg::C4PortraitSelDlg(), C4Network2Res::CalculateSHA(), CopyDirectory(), CStdFile::Create(), C4Network2::CreateDynamic(), C4Network2ResList::CreateNetworkFolder(), C4Network2Res::Derive(), DirectoryExists(), C4StartupNetDlg::DoOK(), C4UpdatePackage::DoUpdate(), EraseDirectory(), C4UpdatePackage::Execute(), C4Config::ExpandEnvironmentVariables(), C4Group::Extract(), C4PlayerList::FileInUse(), C4Network2ResList::FindTempResFileName(), C4Network2Res::FinishDerive(), ForEachFile(), GetFilenameOnly(), C4Group::GetFullName(), C4Language::GetPackGroups(), GetParentPath(), GetWorkingDirectory(), C4Extra::Init(), C4Game::Init(), C4FontLoader::InitFont(), ItemIdentical(), C4DefGraphics::Load(), C4GameResList::Load(), C4Surface::Load(), C4Player::Load(), C4GameResList::LoadFoldersWithLocalDefs(), main(), C4UpdatePackage::MakeUpdate(), C4ObjectInfoList::MakeValidName(), C4MainMenu::MenuCommand(), C4UpdatePackage::MkUp(), CStdFile::Open(), C4Game::OpenScenario(), C4UpdatePackage::Optimize(), C4Network2Res::OptimizeStandalone(), C4Application::ParseCommandLine(), C4Game::QuickSave(), RealPath(), C4Shader::Refresh(), C4GroupSet::RegisterParentFolders(), C4ScriptHost::ReloadScript(), C4Group::Rename(), C4ScenarioListLoader::Entry::RenameTo(), RestartApplication(), C4Network2::RetrieveScenario(), C4ObjectInfo::Save(), C4Player::Save(), C4Landscape::P::SaveInternal(), C4Surface::SavePNG(), C4Console::SaveScenario(), C4GraphicsSystem::SaveScreenshot(), C4LoaderScreen::SeekLoaderScreens(), C4GroupEntry::Set(), C4Network2Res::SetDerived(), C4SDefinitions::SetModules(), C4Game::SetScenarioFilename(), C4Record::Start(), C4Playback::StreamToRecord(), and C4GameSave::WriteDescDefinitions().

#define ALWAYS_INLINE   inline

Definition at line 101 of file PlatformAbstraction.h.

#define BREAKPOINT_HERE   ((void)0)
#define C4_OS   ""

Definition at line 62 of file PlatformAbstraction.h.


Definition at line 99 of file PlatformAbstraction.h.


Definition at line 100 of file PlatformAbstraction.h.

#define NORETURN

Definition at line 102 of file PlatformAbstraction.h.

Typedef Documentation

typedef uint8_t BYTE

Definition at line 135 of file PlatformAbstraction.h.

typedef uint32_t DWORD

Definition at line 134 of file PlatformAbstraction.h.

typedef ptrdiff_t ssize_t

Definition at line 84 of file PlatformAbstraction.h.

typedef uint16_t WORD

Definition at line 136 of file PlatformAbstraction.h.

Function Documentation

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

Referenced by CopyItem().

Here is the caller graph for this function:

bool EraseItemSafe ( const char *  szFilename)

Definition at line 41 of file C4GroupMain.cpp.

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

42 {
43  return false;
44 }

Here is the caller graph for this function:

bool IsGermanSystem ( )

Definition at line 192 of file

Referenced by C4ConfigGeneral::DefaultLanguage().

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

Here is the caller graph for this function:

bool OpenURL ( const char *  szURL)

Definition at line 198 of file

Referenced by C4AppDelegate::visitWebsite:.

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

Here is the caller graph for this function:

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

Definition at line 82 of file PlatformAbstraction.cpp.

References _MAX_PATH, Application, C4Application::argv0, 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 += R"(")";
95  params += p;
96  params += R"(" )";
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 = {Application.argv0};
109  params.insert(params.end(), parameters.begin(), parameters.end());
110  params.push_back(nullptr);
111 #ifdef PROC_SELF_EXE
112  execv(PROC_SELF_EXE, const_cast<char *const *>(;
113  perror("editor launch via " PROC_SELF_EXE " failed");
114 #endif
115  execvp(Application.argv0, const_cast<char *const *>(;
116  perror("editor launch via argv[0] failed");
117  exit(1);
118  }
119  default:
120  success = true;
121  }
122 #endif
123  // must quit ourselves for new instance to be shown
124  if (success) Application.Quit();
125  return success;
126 }
C4Config Config
Definition: C4Config.cpp:833
C4ConfigGeneral General
Definition: C4Config.h:251
#define _MAX_PATH
const char * argv0
Definition: C4Application.h:75
void Quit() override
StdCopyStrBuf ExePath
Definition: C4Config.h:52
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:

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

Definition at line 139 of file PlatformAbstraction.h.

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

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

Here is the caller graph for this function: