diff options
Diffstat (limited to 'drivers/unix')
-rw-r--r-- | drivers/unix/SCsub | 2 | ||||
-rw-r--r-- | drivers/unix/file_access_unix.cpp | 6 | ||||
-rw-r--r-- | drivers/unix/file_access_unix.h | 9 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 39 | ||||
-rw-r--r-- | drivers/unix/os_unix.h | 1 | ||||
-rw-r--r-- | drivers/unix/packet_peer_udp_posix.cpp | 6 | ||||
-rw-r--r-- | drivers/unix/stream_peer_tcp_posix.cpp | 6 | ||||
-rw-r--r-- | drivers/unix/tcp_server_posix.cpp | 6 |
8 files changed, 58 insertions, 17 deletions
diff --git a/drivers/unix/SCsub b/drivers/unix/SCsub index bcd231579c..9fbb467baa 100644 --- a/drivers/unix/SCsub +++ b/drivers/unix/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.drivers_sources,"*.cpp") Export('env') - - diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 76042089ff..8e70ecc932 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -63,7 +63,7 @@ Error FileAccessUnix::_open(const String& p_path, int p_mode_flags) { fclose(f); f=NULL; - String path=fix_path(p_path); + path=fix_path(p_path); //printf("opening %ls, %i\n", path.c_str(), Memory::get_static_mem_usage()); ERR_FAIL_COND_V(f,ERR_ALREADY_IN_USE); @@ -114,6 +114,9 @@ void FileAccessUnix::close() { return; fclose(f); f = NULL; + if (close_notification_func) { + close_notification_func(path,flags); + } if (save_path!="") { //unlink(save_path.utf8().get_data()); @@ -240,6 +243,7 @@ FileAccess * FileAccessUnix::create_libc() { return memnew( FileAccessUnix ); } +CloseNotificationFunc FileAccessUnix::close_notification_func=NULL; FileAccessUnix::FileAccessUnix() { diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h index 5b0f0e7cb7..6c41a51ec5 100644 --- a/drivers/unix/file_access_unix.h +++ b/drivers/unix/file_access_unix.h @@ -38,6 +38,10 @@ /** @author Juan Linietsky <reduzio@gmail.com> */ + + +typedef void (*CloseNotificationFunc)(const String& p_file,int p_flags); + class FileAccessUnix : public FileAccess { FILE *f; @@ -45,10 +49,13 @@ class FileAccessUnix : public FileAccess { void check_errors() const; mutable Error last_error; String save_path; + String path; - static FileAccess* create_libc(); + static FileAccess* create_libc(); public: + static CloseNotificationFunc close_notification_func; + virtual Error _open(const String& p_path, int p_mode_flags); ///< open a file virtual void close(); ///< close a file virtual bool is_open() const; ///< true when file is open diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index f6d9e0fb4e..fd8c26f6d9 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -65,15 +65,25 @@ void OS_Unix::print_error(const char* p_function,const char* p_file,int p_line,c if (!_print_error_enabled) return; - if (p_rationale && p_rationale[0]) { - - print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_rationale); - print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); - - } else { - print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_code); - print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); - + const char* err_details; + if (p_rationale && p_rationale[0]) + err_details=p_rationale; + else + err_details=p_code; + + switch(p_type) { + case ERR_ERROR: + print("\E[1;31mERROR: %s: \E[0m\E[1m%s\n",p_function,err_details); + print("\E[0;31m At: %s:%i.\E[0m\n",p_file,p_line); + break; + case ERR_WARNING: + print("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n",p_function,err_details); + print("\E[0;33m At: %s:%i.\E[0m\n",p_file,p_line); + break; + case ERR_SCRIPT: + print("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m%s\n",p_function,err_details); + print("\E[0;35m At: %s:%i.\E[0m\n",p_file,p_line); + break; } } @@ -223,6 +233,15 @@ uint64_t OS_Unix::get_unix_time() const { return time(NULL); }; +uint64_t OS_Unix::get_system_time_msec() const { + struct timeval tv_now; + gettimeofday(&tv_now, NULL); + //localtime(&tv_now.tv_usec); + //localtime((const long *)&tv_now.tv_usec); + uint64_t msec = uint64_t(tv_now.tv_sec)*1000+tv_now.tv_usec/1000; + return msec; +} + OS::Date OS_Unix::get_date(bool utc) const { @@ -234,7 +253,7 @@ OS::Date OS_Unix::get_date(bool utc) const { lt=localtime(&t); Date ret; ret.year=1900+lt->tm_year; - ret.month=(Month)lt->tm_mon; + ret.month=(Month)(lt->tm_mon + 1); ret.day=lt->tm_mday; ret.weekday=(Weekday)lt->tm_wday; ret.dst=lt->tm_isdst; diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 8bb57eda12..2ee6102164 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -93,6 +93,7 @@ public: virtual TimeZoneInfo get_time_zone_info() const; virtual uint64_t get_unix_time() const; + virtual uint64_t get_system_time_msec() const; virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp index 26a0b29228..94b4c35923 100644 --- a/drivers/unix/packet_peer_udp_posix.cpp +++ b/drivers/unix/packet_peer_udp_posix.cpp @@ -13,7 +13,11 @@ #include <stdio.h> #ifndef NO_FCNTL -#include <sys/fcntl.h> + #ifdef __HAIKU__ + #include <fcntl.h> + #else + #include <sys/fcntl.h> + #endif #else #include <sys/ioctl.h> #endif diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index 2301d8b6c4..5aa3915893 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -39,7 +39,11 @@ #include <netdb.h> #include <sys/types.h> #ifndef NO_FCNTL -#include <sys/fcntl.h> + #ifdef __HAIKU__ + #include <fcntl.h> + #else + #include <sys/fcntl.h> + #endif #else #include <sys/ioctl.h> #endif diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp index 4f9ee62cde..aaca0fe0d8 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -41,7 +41,11 @@ #include <netdb.h> #include <sys/types.h> #ifndef NO_FCNTL -#include <sys/fcntl.h> + #ifdef __HAIKU__ + #include <fcntl.h> + #else + #include <sys/fcntl.h> + #endif #else #include <sys/ioctl.h> #endif |