diff options
Diffstat (limited to 'drivers/unix/os_unix.cpp')
-rw-r--r-- | drivers/unix/os_unix.cpp | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index e2a544b676..0f4e8f757c 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -6,6 +6,7 @@ /* http://www.godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -49,11 +50,12 @@ #include <mach-o/dyld.h> #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) #include <sys/param.h> #endif -#include "global_config.h" +#include "project_settings.h" #include <assert.h> +#include <dlfcn.h> #include <errno.h> #include <poll.h> #include <signal.h> @@ -413,7 +415,7 @@ Error OS_Unix::kill(const ProcessID &p_pid) { return ret ? ERR_INVALID_PARAMETER : OK; } -int OS_Unix::get_process_ID() const { +int OS_Unix::get_process_id() const { return getpid(); }; @@ -435,6 +437,40 @@ String OS_Unix::get_locale() const { return locale; } +Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle) { + p_library_handle = dlopen(p_path.utf8().get_data(), RTLD_NOW); + if (!p_library_handle) { + ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror()); + ERR_FAIL_V(ERR_CANT_OPEN); + } + return OK; +} + +Error OS_Unix::close_dynamic_library(void *p_library_handle) { + if (dlclose(p_library_handle)) { + return FAILED; + } + return OK; +} + +Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) { + const char *error; + dlerror(); // Clear existing errors + + p_symbol_handle = dlsym(p_library_handle, p_name.utf8().get_data()); + + error = dlerror(); + if (error != NULL) { + if (!p_optional) { + ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + error); + ERR_FAIL_V(ERR_CANT_RESOLVE); + } else { + return ERR_CANT_RESOLVE; + } + } + return OK; +} + Error OS_Unix::set_cwd(const String &p_cwd) { if (chdir(p_cwd.utf8().get_data()) != 0) @@ -462,7 +498,7 @@ String OS_Unix::get_data_dir() const { if (has_environment("HOME")) { - bool use_godot = GlobalConfig::get_singleton()->get("application/use_shared_user_dir"); + bool use_godot = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir"); if (use_godot) return get_environment("HOME") + "/.godot/app_userdata/" + an; else @@ -470,12 +506,7 @@ String OS_Unix::get_data_dir() const { } } - return GlobalConfig::get_singleton()->get_resource_path(); -} - -bool OS_Unix::check_feature_support(const String &p_feature) { - - return VisualServer::get_singleton()->has_os_feature(p_feature); + return ProjectSettings::get_singleton()->get_resource_path(); } String OS_Unix::get_installed_templates_path() const { @@ -500,7 +531,7 @@ String OS_Unix::get_executable_path() const { return OS::get_executable_path(); } return b; -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__OpenBSD__) char resolved_path[MAXPATHLEN]; realpath(OS::get_executable_path().utf8().get_data(), resolved_path); |