summaryrefslogtreecommitdiff
path: root/drivers/unix
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/unix')
-rw-r--r--drivers/unix/dir_access_unix.h4
-rw-r--r--drivers/unix/file_access_unix.cpp19
-rw-r--r--drivers/unix/file_access_unix.h4
-rw-r--r--drivers/unix/ip_unix.cpp4
-rw-r--r--drivers/unix/os_unix.cpp20
-rw-r--r--drivers/unix/os_unix.h4
-rw-r--r--drivers/unix/semaphore_posix.h4
-rw-r--r--drivers/unix/thread_posix.h4
8 files changed, 21 insertions, 42 deletions
diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h
index 579cb0e798..88674d2769 100644
--- a/drivers/unix/dir_access_unix.h
+++ b/drivers/unix/dir_access_unix.h
@@ -40,10 +40,6 @@
#include <sys/types.h>
#include <unistd.h>
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-
class DirAccessUnix : public DirAccess {
DIR *dir_stream;
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index a285b3b65f..071734eb48 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -38,6 +38,8 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include <errno.h>
+
#if defined(UNIX_ENABLED)
#include <unistd.h>
#endif
@@ -112,8 +114,15 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
f = fopen(path.utf8().get_data(), mode_string);
if (f == NULL) {
- last_error = ERR_FILE_CANT_OPEN;
- return ERR_FILE_CANT_OPEN;
+ switch (errno) {
+ case ENOENT: {
+ last_error = ERR_FILE_NOT_FOUND;
+ } break;
+ default: {
+ last_error = ERR_FILE_CANT_OPEN;
+ } break;
+ }
+ return last_error;
} else {
last_error = OK;
flags = p_mode_flags;
@@ -288,8 +297,7 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
if (!err) {
return flags.st_mtime;
} else {
- ERR_EXPLAIN("Failed to get modified time for: " + p_file);
- ERR_FAIL_V(0);
+ ERR_FAIL_V_MSG(0, "Failed to get modified time for: " + p_file + ".");
};
}
@@ -302,8 +310,7 @@ uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) {
if (!err) {
return flags.st_mode & 0x7FF; //only permissions
} else {
- ERR_EXPLAIN("Failed to get unix permissions for: " + p_file);
- ERR_FAIL_V(0);
+ ERR_FAIL_V_MSG(0, "Failed to get unix permissions for: " + p_file + ".");
};
}
diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h
index 2a369048a4..e26591e3e8 100644
--- a/drivers/unix/file_access_unix.h
+++ b/drivers/unix/file_access_unix.h
@@ -38,10 +38,6 @@
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-
typedef void (*CloseNotificationFunc)(const String &p_file, int p_flags);
class FileAccessUnix : public FileAccess {
diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp
index ce66f07a19..ac7195abc1 100644
--- a/drivers/unix/ip_unix.cpp
+++ b/drivers/unix/ip_unix.cpp
@@ -184,9 +184,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
continue; // will go back and alloc the right size
};
- ERR_EXPLAIN("Call to GetAdaptersAddresses failed with error " + itos(err));
- ERR_FAIL();
- return;
+ ERR_FAIL_MSG("Call to GetAdaptersAddresses failed with error " + itos(err) + ".");
};
IP_ADAPTER_ADDRESSES *adapter = addrs;
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index aa61cf5dcc..ab5590dba4 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -72,8 +72,7 @@ static double _clock_scale = 0;
static void _setup_clock() {
mach_timebase_info_data_t info;
kern_return_t ret = mach_timebase_info(&info);
- ERR_EXPLAIN("OS CLOCK IS NOT WORKING!");
- ERR_FAIL_COND(ret != 0);
+ ERR_FAIL_COND_MSG(ret != 0, "OS CLOCK IS NOT WORKING!");
_clock_scale = ((double)info.numer / (double)info.denom) / 1000.0;
_clock_start = mach_absolute_time() * _clock_scale;
}
@@ -85,8 +84,7 @@ static void _setup_clock() {
#endif
static void _setup_clock() {
struct timespec tv_now = { 0, 0 };
- ERR_EXPLAIN("OS CLOCK IS NOT WORKING!");
- ERR_FAIL_COND(clock_gettime(GODOT_CLOCK, &tv_now) != 0);
+ ERR_FAIL_COND_MSG(clock_gettime(GODOT_CLOCK, &tv_now) != 0, "OS CLOCK IS NOT WORKING!");
_clock_start = ((uint64_t)tv_now.tv_nsec / 1000L) + (uint64_t)tv_now.tv_sec * 1000000L;
}
#endif
@@ -420,10 +418,7 @@ Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle
}
p_library_handle = dlopen(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);
- }
+ ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + p_path + ". Error: " + dlerror());
return OK;
}
@@ -442,12 +437,9 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S
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;
- }
+ ERR_FAIL_COND_V_MSG(!p_optional, ERR_CANT_RESOLVE, "Can't resolve symbol " + p_name + ". Error: " + error + ".");
+
+ return ERR_CANT_RESOLVE;
}
return OK;
}
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index 53446a6b6f..a263147e23 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -31,10 +31,6 @@
#ifndef OS_UNIX_H
#define OS_UNIX_H
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-
#ifdef UNIX_ENABLED
#include "core/os/os.h"
diff --git a/drivers/unix/semaphore_posix.h b/drivers/unix/semaphore_posix.h
index 089f088d33..83e75c9a82 100644
--- a/drivers/unix/semaphore_posix.h
+++ b/drivers/unix/semaphore_posix.h
@@ -36,9 +36,7 @@
#if defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)
#include <semaphore.h>
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
+
class SemaphorePosix : public Semaphore {
mutable sem_t sem;
diff --git a/drivers/unix/thread_posix.h b/drivers/unix/thread_posix.h
index d6b6267c49..5edacd3a0c 100644
--- a/drivers/unix/thread_posix.h
+++ b/drivers/unix/thread_posix.h
@@ -31,10 +31,6 @@
#ifndef THREAD_POSIX_H
#define THREAD_POSIX_H
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-
#if (defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)) && !defined(NO_THREADS)
#include "core/os/thread.h"