Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
#include "precompiled.h"
#include <unistd.h>
#include <stdio.h>
#include <wchar.h>
#include "lib/code_annotation.h"
#include "lib/utf8.h"
#include "lib/sysdep/os/unix/udbg.h"
#include "lib/sysdep/sysdep.h"
#include <boost/algorithm/string/replace.hpp>
#include <dlfcn.h>
#include <sys/wait.h>
Macros | |
#define | GNU_SOURCE |
#define | URL_OPEN_COMMAND "xdg-open" |
Functions | |
bool | sys_IsDebuggerPresent () |
std::wstring | sys_WideFromArgv (const char *argv_i) |
void | sys_display_msg (const wchar_t *caption, const wchar_t *msg) |
display a message. More... | |
static ErrorReactionInternal | try_gui_display_error (const wchar_t *text, bool manual_break, bool allow_suppress, bool no_continue) |
ErrorReactionInternal | sys_display_error (const wchar_t *text, size_t flags) |
show the error dialog. More... | |
Status | sys_StatusDescription (int err, wchar_t *buf, size_t max_chars) |
describe the current OS error state. More... | |
size_t | sys_max_sector_size () |
return the largest sector size [bytes] of any storage medium (HD, optical, etc.) in the system. More... | |
std::wstring | sys_get_user_name () |
Get the current user's login name. More... | |
Status | sys_generate_random_bytes (u8 *buf, size_t count) |
generate high-quality random bytes. More... | |
Status | sys_get_proxy_config (const std::wstring &url, std::wstring &proxy) |
get the proxy address for accessing the given HTTP URL. More... | |
Status | sys_open_url (const std::string &url) |
Open the user's default web browser to the given URL. More... | |
FILE * | sys_OpenFile (const OsPath &pathname, const char *mode) |
open a file like with fopen (but taking an OsPath argument). More... | |
#define GNU_SOURCE |
#define URL_OPEN_COMMAND "xdg-open" |
ErrorReactionInternal sys_display_error | ( | const wchar_t * | text, |
size_t | flags | ||
) |
show the error dialog.
text | to display (practically unlimited length) |
flags | see DebugDisplayErrorFlags. |
called from debug_DisplayError unless overridden by means of ah_display_error.
void sys_display_msg | ( | const wchar_t * | caption, |
const wchar_t * | msg | ||
) |
display a message.
caption | title message |
msg | message contents |
implemented as a MessageBox on Win32 and printf on Unix. called from debug_DisplayMessage.
generate high-quality random bytes.
this should only be used with small numbers of bytes, to avoid hogging the system's entropy.
Status sys_get_proxy_config | ( | const std::wstring & | url, |
std::wstring & | proxy | ||
) |
get the proxy address for accessing the given HTTP URL.
this may be very slow (tens of seconds).
std::wstring sys_get_user_name | ( | ) |
Get the current user's login name.
bool sys_IsDebuggerPresent | ( | ) |
size_t sys_max_sector_size | ( | ) |
return the largest sector size [bytes] of any storage medium (HD, optical, etc.) in the system.
this may be a bit slow to determine (iterates over all drives), but caches the result so subsequent calls are free. (caveat: device changes won't be noticed during this program run)
sector size is relevant because Windows aio requires all IO buffers, offsets and lengths to be a multiple of it. this requirement is also carried over into the vfs / file.cpp interfaces for efficiency (avoids the need for copying to/from align buffers).
waio uses the sector size to (in some cases) align IOs if they aren't already, but it's also needed by user code when aligning their buffers to meet the requirements.
the largest size is used so that we can read from any drive. while this is a bit wasteful (more padding) and requires iterating over all drives, it is the only safe way: this may be called before we know which drives will be needed, and hardlinks may confuse things.
Status sys_open_url | ( | const std::string & | url | ) |
Open the user's default web browser to the given URL.
FILE * sys_OpenFile | ( | const OsPath & | pathname, |
const char * | mode | ||
) |
open a file like with fopen (but taking an OsPath argument).
Status sys_StatusDescription | ( | int | err, |
wchar_t * | buf, | ||
size_t | max_chars | ||
) |
describe the current OS error state.
err | if not 0, use that as the error code to translate; otherwise, uses GetLastError or similar. |
buf | output buffer |
max_chars |
rationale: it is expected to be rare that OS return/error codes are actually seen by user code, but we leave the possibility open.
std::wstring sys_WideFromArgv | ( | const char * | argv_i | ) |
|
static |