diff options
Diffstat (limited to 'drivers/unix/os_unix.cpp')
-rw-r--r-- | drivers/unix/os_unix.cpp | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 29fe73f170..0d102902e8 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -133,13 +133,6 @@ void OS_Unix::initialize_core() { } } -void OS_Unix::initialize_logger() { - Vector<Logger *> loggers; - loggers.push_back(memnew(UnixTerminalLogger)); - loggers.push_back(memnew(RotatedFileLogger("user://logs/log.txt"))); - _set_logger(memnew(CompositeLogger(loggers))); -} - void OS_Unix::finalize_core() { } @@ -285,7 +278,7 @@ uint64_t OS_Unix::get_ticks_usec() const { return longtime; } -Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode) { +Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr) { if (p_blocking && r_pipe) { @@ -297,7 +290,11 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo argss += String(" \"") + p_arguments[i] + "\""; } - argss += " 2>/dev/null"; //silence stderr + if (read_stderr) { + argss += " 2>&1"; // Read stderr too + } else { + argss += " 2>/dev/null"; //silence stderr + } FILE *f = popen(argss.utf8().get_data(), "r"); ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); @@ -339,7 +336,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo execvp(getprogname(), &args[0]); } #else - execv(p_path.utf8().get_data(), &args[0]); + execvp(p_path.utf8().get_data(), &args[0]); #endif // still alive? something failed.. fprintf(stderr, "**ERROR** OS_Unix::execute - Could not create child process while executing: %s\n", p_path.utf8().get_data()); @@ -448,32 +445,21 @@ int OS_Unix::get_processor_count() const { return sysconf(_SC_NPROCESSORS_CONF); } -String OS_Unix::get_data_dir() const { - - String an = get_safe_application_name(); - if (an != "") { - - if (has_environment("HOME")) { +String OS_Unix::get_user_data_dir() const { - 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 - return get_environment("HOME") + "/." + an; + String appname = get_safe_application_name(); + if (appname != "") { + bool use_godot_dir = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir"); + if (use_godot_dir) { + return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file(appname); + } else { + return get_data_path().plus_file(appname); } } return ProjectSettings::get_singleton()->get_resource_path(); } -String OS_Unix::get_installed_templates_path() const { - String p = get_global_settings_path(); - if (p != "") - return p + "/templates/"; - else - return ""; -} - String OS_Unix::get_executable_path() const { #ifdef __linux__ @@ -548,4 +534,10 @@ void UnixTerminalLogger::log_error(const char *p_function, const char *p_file, i UnixTerminalLogger::~UnixTerminalLogger() {} +OS_Unix::OS_Unix() { + Vector<Logger *> loggers; + loggers.push_back(memnew(UnixTerminalLogger)); + _set_logger(memnew(CompositeLogger(loggers))); +} + #endif |