Minetest  5.4.0
porting Namespace Reference

Functions

bool * signal_handler_killstatus ()
 
void signal_handler (int sig)
 
void signal_handler_init (void)
 
std::string getDataPath (const char *subpath)
 
void pathRemoveFile (char *path, char delim)
 
bool detectMSVCBuildDir (const std::string &path)
 
std::string get_sysinfo ()
 
bool getCurrentWorkingDir (char *buf, size_t len)
 
bool getExecPathFromProcfs (char *buf, size_t buflen)
 
bool getCurrentExecPath (char *buf, size_t len)
 
const char * getHomeOrFail ()
 
bool setSystemPaths ()
 
void migrateCachePath ()
 
void initializePaths ()
 
bool secure_rand_fill_buf (void *buf, size_t len)
 
void attachOrCreateConsole ()
 
int mt_snprintf (char *buf, const size_t buf_size, const char *fmt,...)
 
static bool open_uri (const std::string &uri)
 
bool open_url (const std::string &url)
 Opens URL in default web browser. More...
 
bool open_directory (const std::string &path)
 Opens a directory in the default file manager. More...
 
void os_get_clock (struct timespec *ts)
 
u64 getTimeS ()
 
u64 getTimeMs ()
 
u64 getTimeUs ()
 
u64 getTimeNs ()
 
u64 getTime (TimePrecision prec)
 
u64 getDeltaMs (u64 old_time_ms, u64 new_time_ms)
 Delta calculation function arguments. More...
 
const char * getPlatformName ()
 
jclass findClass (const std::string &classname)
 
void initAndroid ()
 
void cleanupAndroid ()
 
static std::string javaStringToUTF8 (jstring js)
 
static std::string getAndroidPath (jclass cls, jobject obj, jmethodID mt_getAbsPath, const char *getter)
 
void initializePathsAndroid ()
 Initializes path_* variables for Android. More...
 
void showInputDialog (const std::string &acceptButton, const std::string &hint, const std::string &current, int editType)
 show text input dialog in java More...
 
void openURIAndroid (const std::string &url)
 
int getInputDialogState ()
 WORKAROUND for not working callbacks from java -> c++ get current state of input dialog. More...
 
std::string getInputDialogValue ()
 WORKAROUND for not working callbacks from java -> c++ get text in current input dialog. More...
 
float getDisplayDensity ()
 
v2u32 getDisplaySize ()
 

Variables

bool g_killed = false
 
std::string path_share = ".."
 
std::string path_user = ".."
 
std::string path_locale = path_share + DIR_DELIM + "locale"
 
std::string path_cache = path_user + DIR_DELIM + "cache"
 
android_app * app_global
 
JNIEnv * jnienv
 
jclass nativeActivity
 

Function Documentation

◆ attachOrCreateConsole()

void porting::attachOrCreateConsole ( )

Referenced by main().

+ Here is the caller graph for this function:

◆ cleanupAndroid()

void porting::cleanupAndroid ( )

References app_global, DIR_DELIM, errorstream, and path_user.

Referenced by android_main().

+ Here is the caller graph for this function:

◆ detectMSVCBuildDir()

bool porting::detectMSVCBuildDir ( const std::string &  path)

References removeStringEnd().

Referenced by initializePaths().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findClass()

jclass porting::findClass ( const std::string &  classname)

References app_global, and jnienv.

Referenced by initAndroid().

+ Here is the caller graph for this function:

◆ get_sysinfo()

std::string porting::get_sysinfo ( )

◆ getAndroidPath()

static std::string porting::getAndroidPath ( jclass  cls,
jobject  obj,
jmethodID  mt_getAbsPath,
const char *  getter 
)
static

References javaStringToUTF8(), and jnienv.

Referenced by initializePathsAndroid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentExecPath()

bool porting::getCurrentExecPath ( char *  buf,
size_t  len 
)

Referenced by initializePaths().

+ Here is the caller graph for this function:

◆ getCurrentWorkingDir()

bool porting::getCurrentWorkingDir ( char *  buf,
size_t  len 
)

Referenced by initializePaths().

+ Here is the caller graph for this function:

◆ getDataPath()

std::string porting::getDataPath ( const char *  subpath)

References DIR_DELIM, and path_share.

Referenced by initializePaths(), and set_default_settings().

+ Here is the caller graph for this function:

◆ getDeltaMs()

u64 porting::getDeltaMs ( u64  old_time_ms,
u64  new_time_ms 
)
inline

Delta calculation function arguments.

Parameters
old_time_msold time for delta calculation
new_time_msnew time for delta calculation
Returns
positive delta value

Referenced by GUIModalMenu::DoubleClickDetection(), TouchScreenGUI::doubleTapDetection(), GUIScene::draw(), drawItemStack(), GUIFormSpecMenu::drawMenu(), and TouchScreenGUI::step().

+ Here is the caller graph for this function:

◆ getDisplayDensity()

float porting::getDisplayDensity ( )

References app_global, FATAL_ERROR_IF, jnienv, and nativeActivity.

Referenced by GUIModalMenu::GUIModalMenu(), TouchScreenGUI::TouchScreenGUI(), GUIConfirmRegistration::regenerateGui(), GUIPasswordChange::regenerateGui(), ClientLauncher::run(), and set_default_settings().

+ Here is the caller graph for this function:

◆ getDisplaySize()

v2u32 porting::getDisplaySize ( )

References app_global, FATAL_ERROR_IF, jnienv, and nativeActivity.

Referenced by set_default_settings().

+ Here is the caller graph for this function:

◆ getExecPathFromProcfs()

bool porting::getExecPathFromProcfs ( char *  buf,
size_t  buflen 
)

Referenced by initializePaths().

+ Here is the caller graph for this function:

◆ getHomeOrFail()

const char* porting::getHomeOrFail ( )

References FATAL_ERROR_IF.

Referenced by setSystemPaths().

+ Here is the caller graph for this function:

◆ getInputDialogState()

int porting::getInputDialogState ( )

WORKAROUND for not working callbacks from java -> c++ get current state of input dialog.

References app_global, FATAL_ERROR_IF, jnienv, and nativeActivity.

◆ getInputDialogValue()

std::string porting::getInputDialogValue ( )

WORKAROUND for not working callbacks from java -> c++ get text in current input dialog.

References app_global, FATAL_ERROR_IF, jnienv, and nativeActivity.

◆ getPlatformName()

const char* porting::getPlatformName ( )
inline

Referenced by ScriptApiBase::ScriptApiBase(), and print_version().

+ Here is the caller graph for this function:

◆ getTime()

u64 porting::getTime ( TimePrecision  prec)
inline

References FATAL_ERROR, getTimeMs(), getTimeNs(), getTimeS(), getTimeUs(), PRECISION_MICRO, PRECISION_MILLI, PRECISION_NANO, and PRECISION_SECONDS.

Referenced by TimeTaker::TimeTaker(), TimeTaker::getTimerTime(), and TimeTaker::stop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimeMs()

u64 porting::getTimeMs ( )
inline

References os_get_clock().

Referenced by Profiler::Profiler(), Client::afterContentReceived(), Database_SQLite3::busyHandler(), Profiler::clear(), GUIModalMenu::DoubleClickDetection(), TouchScreenGUI::doubleTapDetection(), GUIChatConsole::draw(), GUIEditBoxWithScrollBar::draw(), GUIScene::draw(), irr::gui::intlGUIEditBox::draw(), GUIAnimatedImage::draw(), drawItemStack(), GUIFormSpecMenu::drawMenu(), GUIButton::drawSprite(), Profiler::getElapsedMs(), getTime(), JoystickController::handleEvent(), con::ConnectionReceiveThread::handlePacketType_Control(), GUIEditBox::inputChar(), con::Peer::isTimedOut(), ServerModManager::loadMods(), GUITable::OnEvent(), GUIButton::OnEvent(), GUIEditBox::onKeyBack(), GUIEditBox::onKeyDelete(), GameGlobalShaderConstantSetter::onSetConstants(), GUIChatConsole::openConsole(), GUIEditBox::processKey(), GUIEditBox::processMouse(), Client::ReceiveAll(), con::ConnectionSendThread::run(), con::ConnectionReceiveThread::run(), run_tests(), con::ConnectionSendThread::sendAsPacketReliable(), GUIButton::setPressed(), TouchScreenGUI::step(), TestConnection::testConnectSendReceive(), TestBase::testModule(), texture_update_progress(), Map::transformLiquids(), TouchScreenGUI::translateEvent(), and Game::updatePointedThing().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimeNs()

u64 porting::getTimeNs ( )
inline

References os_get_clock().

Referenced by getTime(), and ServerMap::save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimeS()

u64 porting::getTimeS ( )
inline

References os_get_clock().

Referenced by getTime(), and RemoteClient::uptime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimeUs()

u64 porting::getTimeUs ( )
inline

References os_get_clock().

Referenced by getTime(), ModApiBase::l_deprecated_function(), and ModApiUtil::l_get_us_time().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initAndroid()

void porting::initAndroid ( )

References app_global, errorstream, findClass(), jnienv, nativeActivity, and PROJECT_NAME_C.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializePaths()

void porting::initializePaths ( )

References detectMSVCBuildDir(), DIR_DELIM, DIR_DELIM_CHAR, errorstream, FATAL_ERROR, getCurrentExecPath(), getCurrentWorkingDir(), getDataPath(), getExecPathFromProcfs(), infostream, migrateCachePath(), path_cache, path_locale, path_share, path_user, fs::PathExists(), pathRemoveFile(), PROJECT_NAME, setSystemPaths(), STATIC_LOCALEDIR, and warningstream.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializePathsAndroid()

void porting::initializePathsAndroid ( )

Initializes path_* variables for Android.

Parameters
envAndroid JNI environment

References app_global, DIR_DELIM, getAndroidPath(), jnienv, migrateCachePath(), nativeActivity, path_cache, path_share, path_user, and PROJECT_NAME_C.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ javaStringToUTF8()

static std::string porting::javaStringToUTF8 ( jstring  js)
static

References jnienv.

Referenced by getAndroidPath().

+ Here is the caller graph for this function:

◆ migrateCachePath()

void porting::migrateCachePath ( )

References DIR_DELIM, errorstream, path_cache, path_user, fs::PathExists(), fs::RecursiveDelete(), and fs::Rename().

Referenced by initializePaths(), and initializePathsAndroid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mt_snprintf()

int porting::mt_snprintf ( char *  buf,
const size_t  buf_size,
const char *  fmt,
  ... 
)

◆ open_directory()

bool porting::open_directory ( const std::string &  path)

Opens a directory in the default file manager.

The directory must exist.

Parameters
pathPath to directory
Returns
true on success, false on failure

References errorstream, fs::IsDir(), and open_uri().

Referenced by ModApiMainMenu::l_open_dir().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ open_uri()

static bool porting::open_uri ( const std::string &  uri)
static

References errorstream, and openURIAndroid().

Referenced by open_directory(), and open_url().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ open_url()

bool porting::open_url ( const std::string &  url)

Opens URL in default web browser.

Must begin with http:// or https://, and not contain any new lines

Parameters
urlThe URL
Returns
true on success, false on failure

References errorstream, and open_uri().

Referenced by ModApiMainMenu::Initialize(), and ModApiMainMenu::l_open_url().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openURIAndroid()

void porting::openURIAndroid ( const std::string &  url)

References app_global, FATAL_ERROR_IF, jnienv, and nativeActivity.

Referenced by open_uri().

+ Here is the caller graph for this function:

◆ os_get_clock()

void porting::os_get_clock ( struct timespec *  ts)
inline

Referenced by getTimeMs(), getTimeNs(), getTimeS(), and getTimeUs().

+ Here is the caller graph for this function:

◆ pathRemoveFile()

void porting::pathRemoveFile ( char *  path,
char  delim 
)

Referenced by initializePaths().

+ Here is the caller graph for this function:

◆ secure_rand_fill_buf()

bool porting::secure_rand_fill_buf ( void *  buf,
size_t  len 
)

Referenced by LuaSecureRandom::fillRandBuf(), and httpfetch_init().

+ Here is the caller graph for this function:

◆ setSystemPaths()

bool porting::setSystemPaths ( )

References DIR_DELIM, getHomeOrFail(), lowercase(), path_share, path_user, PROJECT_NAME, and STATIC_SHAREDIR.

Referenced by initializePaths().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showInputDialog()

void porting::showInputDialog ( const std::string &  acceptButton,
const std::string &  hint,
const std::string &  current,
int  editType 
)

show text input dialog in java

Parameters
acceptButtontext to display on accept button
hinthint to show
currentinitial value to display
editTypetype of texfield (1==multiline text input; 2==single line text input; 3=password field)

References app_global, FATAL_ERROR_IF, jnienv, and nativeActivity.

Referenced by Game::openConsole(), and GUIModalMenu::preprocessEvent().

+ Here is the caller graph for this function:

◆ signal_handler()

void porting::signal_handler ( int  sig)

References dstream, and g_killed.

Referenced by signal_handler_init().

+ Here is the caller graph for this function:

◆ signal_handler_init()

void porting::signal_handler_init ( void  )

References signal_handler().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ signal_handler_killstatus()

bool * porting::signal_handler_killstatus ( )

References g_killed.

Referenced by ClientLauncher::launch_game(), ClientLauncher::main_menu(), migrate_map_database(), ClientLauncher::run(), and run_dedicated_server().

+ Here is the caller graph for this function:

Variable Documentation

◆ app_global

◆ g_killed

bool porting::g_killed = false

◆ jnienv

◆ nativeActivity

◆ path_cache

◆ path_locale

std::string porting::path_locale = path_share + DIR_DELIM + "locale"

Referenced by init_common(), and initializePaths().

◆ path_share

◆ path_user