diff options
Diffstat (limited to 'drivers/unix')
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 7 | ||||
-rw-r--r-- | drivers/unix/dir_access_unix.h | 3 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 17 | ||||
-rw-r--r-- | drivers/unix/semaphore_posix.cpp | 87 | ||||
-rw-r--r-- | drivers/unix/semaphore_posix.h | 58 |
5 files changed, 15 insertions, 157 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 02cb4fa956..715bc56003 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -269,6 +269,11 @@ String DirAccessUnix::get_drive(int p_drive) { return list[p_drive]; } +bool DirAccessUnix::drives_are_shortcuts() { + + return true; +} + Error DirAccessUnix::make_dir(String p_dir) { GLOBAL_LOCK_FUNCTION @@ -337,7 +342,7 @@ Error DirAccessUnix::change_dir(String p_dir) { return OK; } -String DirAccessUnix::get_current_dir() { +String DirAccessUnix::get_current_dir(bool p_include_drive) { String base = _get_root_path(); if (base != "") { diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h index 32ddc76638..b403d8e356 100644 --- a/drivers/unix/dir_access_unix.h +++ b/drivers/unix/dir_access_unix.h @@ -63,9 +63,10 @@ public: virtual int get_drive_count(); virtual String get_drive(int p_drive); + virtual bool drives_are_shortcuts(); virtual Error change_dir(String p_dir); ///< can be relative or absolute, return false on success - virtual String get_current_dir(); ///< return current dir location + virtual String get_current_dir(bool p_include_drive = true); ///< return current dir location virtual Error make_dir(String p_dir); virtual bool file_exists(String p_file); diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 1d94b9618d..458488f3e9 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -32,13 +32,14 @@ #ifdef UNIX_ENABLED +#include "core/debugger/engine_debugger.h" +#include "core/debugger/script_debugger.h" #include "core/os/thread_dummy.h" #include "core/project_settings.h" #include "drivers/unix/dir_access_unix.h" #include "drivers/unix/file_access_unix.h" #include "drivers/unix/net_socket_posix.h" #include "drivers/unix/rw_lock_posix.h" -#include "drivers/unix/semaphore_posix.h" #include "drivers/unix/thread_posix.h" #include "servers/visual_server.h" @@ -95,16 +96,16 @@ void OS_Unix::debug_break() { }; static void handle_interrupt(int sig) { - if (ScriptDebugger::get_singleton() == NULL) + if (!EngineDebugger::is_active()) return; - ScriptDebugger::get_singleton()->set_depth(-1); - ScriptDebugger::get_singleton()->set_lines_left(1); + EngineDebugger::get_script_debugger()->set_depth(-1); + EngineDebugger::get_script_debugger()->set_lines_left(1); } void OS_Unix::initialize_debugging() { - if (ScriptDebugger::get_singleton() != NULL) { + if (EngineDebugger::is_active()) { struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = handle_interrupt; @@ -121,13 +122,9 @@ void OS_Unix::initialize_core() { #ifdef NO_THREADS ThreadDummy::make_default(); - SemaphoreDummy::make_default(); RWLockDummy::make_default(); #else ThreadPosix::make_default(); -#if !defined(OSX_ENABLED) && !defined(IPHONE_ENABLED) - SemaphorePosix::make_default(); -#endif RWLockPosix::make_default(); #endif FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES); @@ -307,7 +304,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo if (p_pipe_mutex) { p_pipe_mutex->lock(); } - (*r_pipe) += buf; + (*r_pipe) += String::utf8(buf); if (p_pipe_mutex) { p_pipe_mutex->unlock(); } diff --git a/drivers/unix/semaphore_posix.cpp b/drivers/unix/semaphore_posix.cpp deleted file mode 100644 index b532b09cd6..0000000000 --- a/drivers/unix/semaphore_posix.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************************************/ -/* semaphore_posix.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 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 */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "semaphore_posix.h" - -#if (defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)) && !defined(OSX_ENABLED) && !defined(IPHONE_ENABLED) - -#include "core/os/memory.h" -#include <errno.h> -#include <stdio.h> - -Error SemaphorePosix::wait() { - - while (sem_wait(&sem)) { - if (errno == EINTR) { - errno = 0; - continue; - } else { - perror("sem waiting"); - return ERR_BUSY; - } - } - return OK; -} - -Error SemaphorePosix::post() { - - return (sem_post(&sem) == 0) ? OK : ERR_BUSY; -} -int SemaphorePosix::get() const { - - int val; - sem_getvalue(&sem, &val); - - return val; -} - -SemaphoreOld *SemaphorePosix::create_semaphore_posix() { - - return memnew(SemaphorePosix); -} - -void SemaphorePosix::make_default() { - - create_func = create_semaphore_posix; -} - -SemaphorePosix::SemaphorePosix() { - - int r = sem_init(&sem, 0, 0); - if (r != 0) - perror("sem creating"); -} - -SemaphorePosix::~SemaphorePosix() { - - sem_destroy(&sem); -} - -#endif diff --git a/drivers/unix/semaphore_posix.h b/drivers/unix/semaphore_posix.h deleted file mode 100644 index 2bffe6933d..0000000000 --- a/drivers/unix/semaphore_posix.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************/ -/* semaphore_posix.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 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 */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef SEMAPHORE_POSIX_H -#define SEMAPHORE_POSIX_H - -#include "core/os/semaphore.h" - -#if (defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)) && !defined(OSX_ENABLED) && !defined(IPHONE_ENABLED) - -#include <semaphore.h> - -class SemaphorePosix : public SemaphoreOld { - - mutable sem_t sem; - - static SemaphoreOld *create_semaphore_posix(); - -public: - virtual Error wait(); - virtual Error post(); - virtual int get() const; - - static void make_default(); - SemaphorePosix(); - - ~SemaphorePosix(); -}; - -#endif -#endif |