Polyphase Game Engine
Loading...
Searching...
No Matches
System.h
Go to the documentation of this file.
1#pragma once
2
3#include "PolyphaseAPI.h"
5
6#include <string>
7#include <vector>
8#include <stdarg.h>
9
10class Stream;
11
15
16// Files
17bool SYS_DoesFileExist(const char* path, bool isAsset);
18void SYS_AcquireFileData(const char* path, bool isAsset, int32_t maxSize, char*& outData, uint32_t& outSize);
19void SYS_ReleaseFileData(char* data);
23std::string SYS_GetAbsolutePath(const std::string& relativePath);
24void SYS_ExplorerOpenDirectory(const std::string& dirPath);
25void SYS_OpenFileWithDefaultApp(const std::string& filePath);
26void SYS_SetWorkingDirectory(const std::string& dirPath);
27bool SYS_CreateDirectory(const char* dirPath);
28void SYS_RemoveDirectory(const char* dirPath);
29void SYS_OpenDirectory(const std::string& dirPath, DirEntry& outDirEntry);
31void SYS_CopyDirectory(const char* sourceDir, const char* destDir);
32void SYS_CopyFile(const char* sourcePath, const char* destPath);
33bool SYS_CopyDirectoryRecursive(const std::string& sourceDir,
34 const std::string& destDir);
35void SYS_MoveDirectory(const char* sourceDir, const char* destDir);
36void SYS_MoveFile(const char* sourcePath, const char* destPath);
38void SYS_RemoveFile(const char* path);
39bool SYS_Rename(const char* oldPath, const char* newPath);
40std::vector<std::string> SYS_OpenFileDialog();
41std::string SYS_SaveFileDialog();
43std::string SYS_GetFileName(const std::string& path);
44
45// Pulls any files the OS has dropped on the editor window since the last call
46// and moves them into outPaths. Empty on non-editor builds (DragAcceptFiles is
47// not registered) and on platforms whose windowing layer doesn't have drop
48// support wired yet (Linux XCB, Android, consoles).
49void SYS_DrainDroppedFiles(std::vector<std::string>& outPaths);
50
51// Threading — exported so native addons can use them without relinking the engine's
52// implementation. See AsyncMediaPump in the VideoPlayer addon for a reference consumer.
53POLYPHASE_API ThreadObject* SYS_CreateThread(ThreadFuncFP func, void* arg);
54POLYPHASE_API void SYS_JoinThread(ThreadObject* thread);
55POLYPHASE_API void SYS_DestroyThread(ThreadObject* thread);
57POLYPHASE_API void SYS_LockMutex(MutexObject* mutex);
58POLYPHASE_API void SYS_UnlockMutex(MutexObject* mutex);
59POLYPHASE_API void SYS_DestroyMutex(MutexObject* mutex);
60POLYPHASE_API void SYS_Sleep(uint32_t milliseconds);
61
62// Time
64
65// Process
66void SYS_Exec(const char* cmd, std::string* output = nullptr);
67
80bool SYS_ExecFull(const char* cmd, std::string* outStdout, std::string* outStderr, int* outExitCode);
81
99void SYS_ExecDetached(const char* cmd);
100
121bool SYS_KillProcessByName(const char* processName);
122
145bool SYS_SpawnDetachedExecutable(const char* exePath, const char* args);
146
147// Memory
148void* SYS_AlignedMalloc(uint32_t size, uint32_t alignment);
149void SYS_AlignedFree(void* pointer);
150std::vector<MemoryStat> SYS_GetMemoryStats();
160
161// Save / Memcard
162bool SYS_ReadSave(const char* saveName, Stream& outStream);
163bool SYS_WriteSave(const char* saveName, Stream& stream);
164bool SYS_DoesSaveExist(const char* saveName);
165bool SYS_DeleteSave(const char* saveName);
167
168// Clipboard
169void SYS_SetClipboardText(const std::string& str);
171
172// Misc
173void SYS_Log(LogSeverity severity, const char* format, va_list arg);
174POLYPHASE_API void SYS_Assert(const char* exprString, const char* fileString, uint32_t lineNumber);
175void SYS_Alert(const char* message);
178void SYS_SetWindowTitle(const char* title);
179void SYS_SetWindowIcon(const char* iconPath);
183void SYS_SetFullscreen(bool fullscreen);
185void SYS_SetWindowRect(int32_t x, int32_t y, int32_t width, int32_t height);
186void SYS_GetWindowRect(int32_t& outX, int32_t& outY, int32_t& outWidth, int32_t& outHeight);
189
191{
192 ScopedLock(MutexObject* mutex)
193 {
194 mMutex = mutex;
196 }
197
199 {
201 }
202
203 MutexObject* mMutex = nullptr;
204};
205
206#define SCOPED_LOCK(mutex) ScopedLock scopedLock(mutex)
207
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
ThreadFuncRet(* ThreadFuncFP)(void *)
Definition SystemTypes.h:71
LogSeverity
Definition SystemTypes.h:169
ScreenOrientation
Definition SystemTypes.h:83
float SYS_GetVRAMUsage()
POLYPHASE_API uint64_t SYS_GetTimeMicroseconds()
POLYPHASE_API void SYS_UnlockMutex(MutexObject *mutex)
std::string SYS_GetAbsolutePath(const std::string &relativePath)
std::string SYS_GetFileName(const std::string &path)
bool SYS_ExecFull(const char *cmd, std::string *outStdout, std::string *outStderr, int *outExitCode)
Execute a command with full output capture.
Definition SystemUtils.cpp:340
std::string SYS_SaveFileDialog()
void SYS_CopyDirectory(const char *sourceDir, const char *destDir)
std::vector< MemoryStat > SYS_GetMemoryStats()
void SYS_CloseDirectory(DirEntry &dirEntry)
void SYS_IterateDirectory(DirEntry &dirEntry)
void SYS_MaximizeWindow()
POLYPHASE_API ThreadObject * SYS_CreateThread(ThreadFuncFP func, void *arg)
void SYS_AcquireFileData(const char *path, bool isAsset, int32_t maxSize, char *&outData, uint32_t &outSize)
POLYPHASE_API void SYS_Assert(const char *exprString, const char *fileString, uint32_t lineNumber)
std::string SYS_GetCurrentDirectoryPath()
bool SYS_DoesFileExist(const char *path, bool isAsset)
bool SYS_SpawnDetachedExecutable(const char *exePath, const char *args)
Spawn a detached, fully-independent copy of an executable.
float SYS_GetRAM2Usage()
void SYS_ExplorerOpenDirectory(const std::string &dirPath)
std::string SYS_GetPolyphasePath()
bool SYS_DoesWindowHaveFocus()
float SYS_GetRAM1Usage()
float SYS_GetTotalVRAM()
bool SYS_CreateDirectory(const char *dirPath)
void SYS_Exec(const char *cmd, std::string *output=nullptr)
float SYS_GetTotalRAM()
void SYS_MoveDirectory(const char *sourceDir, const char *destDir)
void SYS_SetWindowRect(int32_t x, int32_t y, int32_t width, int32_t height)
float SYS_GetCPUUsage()
bool SYS_DeleteSave(const char *saveName)
void * SYS_AlignedMalloc(uint32_t size, uint32_t alignment)
void SYS_Update()
void SYS_Alert(const char *message)
float SYS_GetRAMUsage()
void SYS_SetWindowIcon(const char *iconPath)
void SYS_SetFullscreen(bool fullscreen)
bool SYS_WriteSave(const char *saveName, Stream &stream)
void SYS_UpdateConsole()
void SYS_OpenDirectory(const std::string &dirPath, DirEntry &outDirEntry)
void SYS_AlignedFree(void *pointer)
void SYS_RemoveDirectory(const char *dirPath)
std::vector< std::string > SYS_OpenFileDialog()
POLYPHASE_API void SYS_LockMutex(MutexObject *mutex)
void SYS_SetClipboardText(const std::string &str)
void SYS_SetScreenOrientation(ScreenOrientation orientation)
void SYS_CopyFile(const char *sourcePath, const char *destPath)
void SYS_ExecDetached(const char *cmd)
Fire-and-forget process spawn that NEVER blocks the caller.
std::string SYS_GetClipboardText()
POLYPHASE_API void SYS_DestroyMutex(MutexObject *mutex)
void SYS_Shutdown()
ScreenOrientation SYS_GetScreenOrientation()
bool SYS_Rename(const char *oldPath, const char *newPath)
void SYS_DrainDroppedFiles(std::vector< std::string > &outPaths)
float SYS_GetTotalRAM2()
POLYPHASE_API void SYS_Sleep(uint32_t milliseconds)
void SYS_Initialize()
std::string SYS_SelectFolderDialog()
bool SYS_IsWindowMaximized()
void SYS_GetWindowRect(int32_t &outX, int32_t &outY, int32_t &outWidth, int32_t &outHeight)
void SYS_OpenFileWithDefaultApp(const std::string &filePath)
POLYPHASE_API MutexObject * SYS_CreateMutex()
void SYS_MoveFile(const char *sourcePath, const char *destPath)
bool SYS_IsFullscreen()
POLYPHASE_API void SYS_JoinThread(ThreadObject *thread)
bool SYS_CopyDirectoryRecursive(const std::string &sourceDir, const std::string &destDir)
void SYS_SetWorkingDirectory(const std::string &dirPath)
void SYS_SetWindowTitle(const char *title)
bool SYS_ReadSave(const char *saveName, Stream &outStream)
bool SYS_KillProcessByName(const char *processName)
Terminate every running process matching an image name.
void SYS_UnmountMemoryCard()
float SYS_GetTotalRAM1()
void SYS_ReleaseFileData(char *data)
int32_t SYS_GetPlatformTier()
std::string SYS_GetExecutablePath()
void SYS_RemoveFile(const char *path)
void SYS_Log(LogSeverity severity, const char *format, va_list arg)
POLYPHASE_API void SYS_DestroyThread(ThreadObject *thread)
bool SYS_DoesSaveExist(const char *saveName)
Definition Stream.h:21
Definition SystemTypes.h:92
Definition System.h:191
ScopedLock(MutexObject *mutex)
Definition System.h:192
MutexObject * mMutex
Definition System.h:203
~ScopedLock()
Definition System.h:198