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// Threading — exported so native addons can use them without relinking the engine's
46// implementation. See AsyncMediaPump in the VideoPlayer addon for a reference consumer.
47POLYPHASE_API ThreadObject* SYS_CreateThread(ThreadFuncFP func, void* arg);
48POLYPHASE_API void SYS_JoinThread(ThreadObject* thread);
49POLYPHASE_API void SYS_DestroyThread(ThreadObject* thread);
51POLYPHASE_API void SYS_LockMutex(MutexObject* mutex);
52POLYPHASE_API void SYS_UnlockMutex(MutexObject* mutex);
53POLYPHASE_API void SYS_DestroyMutex(MutexObject* mutex);
54POLYPHASE_API void SYS_Sleep(uint32_t milliseconds);
55
56// Time
58
59// Process
60void SYS_Exec(const char* cmd, std::string* output = nullptr);
61
74bool SYS_ExecFull(const char* cmd, std::string* outStdout, std::string* outStderr, int* outExitCode);
75
76// Memory
77void* SYS_AlignedMalloc(uint32_t size, uint32_t alignment);
78void SYS_AlignedFree(void* pointer);
79std::vector<MemoryStat> SYS_GetMemoryStats();
89
90// Save / Memcard
91bool SYS_ReadSave(const char* saveName, Stream& outStream);
92bool SYS_WriteSave(const char* saveName, Stream& stream);
93bool SYS_DoesSaveExist(const char* saveName);
94bool SYS_DeleteSave(const char* saveName);
96
97// Clipboard
98void SYS_SetClipboardText(const std::string& str);
100
101// Misc
102void SYS_Log(LogSeverity severity, const char* format, va_list arg);
103POLYPHASE_API void SYS_Assert(const char* exprString, const char* fileString, uint32_t lineNumber);
104void SYS_Alert(const char* message);
107void SYS_SetWindowTitle(const char* title);
108void SYS_SetWindowIcon(const char* iconPath);
112void SYS_SetFullscreen(bool fullscreen);
114void SYS_SetWindowRect(int32_t x, int32_t y, int32_t width, int32_t height);
115void SYS_GetWindowRect(int32_t& outX, int32_t& outY, int32_t& outWidth, int32_t& outHeight);
118
120{
121 ScopedLock(MutexObject* mutex)
122 {
123 mMutex = mutex;
125 }
126
128 {
130 }
131
132 MutexObject* mMutex = nullptr;
133};
134
135#define SCOPED_LOCK(mutex) ScopedLock scopedLock(mutex)
136
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
ThreadFuncRet(* ThreadFuncFP)(void *)
Definition SystemTypes.h:57
LogSeverity
Definition SystemTypes.h:139
ScreenOrientation
Definition SystemTypes.h:66
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:63
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)
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)
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)
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)
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:75
Definition System.h:120
ScopedLock(MutexObject *mutex)
Definition System.h:121
MutexObject * mMutex
Definition System.h:132
~ScopedLock()
Definition System.h:127