diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 20 | ||||
-rw-r--r-- | drivers/unix/dir_access_unix.h | 4 | ||||
-rw-r--r-- | drivers/unix/tcp_server_posix.cpp | 3 | ||||
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 33 | ||||
-rw-r--r-- | drivers/windows/dir_access_windows.h | 1 |
5 files changed, 60 insertions, 1 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index fff86c5a7e..452d791d96 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -81,6 +81,26 @@ bool DirAccessUnix::file_exists(String p_file) { } +bool DirAccessUnix::dir_exists(String p_dir) { + + GLOBAL_LOCK_FUNCTION + + + if (p_dir.is_rel_path()) + p_dir=current_dir+"/"+p_dir; + else + p_dir=fix_path(p_dir); + + struct stat flags; + bool success = (stat(p_dir.utf8().get_data(),&flags)==0); + + if (success && S_ISDIR(flags.st_mode)) + return true; + + return false; + +} + uint64_t DirAccessUnix::get_modified_time(String p_file) { if (p_file.is_rel_path()) diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h index 7ede4fc31c..119cb5c3f4 100644 --- a/drivers/unix/dir_access_unix.h +++ b/drivers/unix/dir_access_unix.h @@ -66,7 +66,9 @@ public: virtual String get_current_dir(); ///< return current dir location virtual Error make_dir(String p_dir); - virtual bool file_exists(String p_file); + virtual bool file_exists(String p_file); + virtual bool dir_exists(String p_dir); + virtual uint64_t get_modified_time(String p_file); diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp index f91ad36ef9..dfcf479fc0 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -93,6 +93,9 @@ Error TCPServerPosix::listen(uint16_t p_port,const List<String> *p_accepted_host close(sockfd); ERR_FAIL_V(FAILED); }; + } + else { + return ERR_ALREADY_IN_USE; }; if (listen_sockfd != -1) { diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 30f6ff6d8c..aacd02ca24 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -303,6 +303,39 @@ bool DirAccessWindows::file_exists(String p_file) { return false; } +bool DirAccessWindows::dir_exists(String p_dir) { + + GLOBAL_LOCK_FUNCTION + + if (!p_dir.is_abs_path()) + p_dir=get_current_dir()+"/"+p_dir; + p_dir=fix_path(p_dir); + + p_dir.replace("/","\\"); + + if (unicode) { + + DWORD fileAttr; + + fileAttr = GetFileAttributesW(p_dir.c_str()); + if (0xFFFFFFFF == fileAttr) + return false; + + return (fileAttr&FILE_ATTRIBUTE_DIRECTORY); + + } else { + DWORD fileAttr; + + fileAttr = GetFileAttributesA(p_dir.ascii().get_data()); + if (0xFFFFFFFF == fileAttr) + return false; + return (fileAttr&FILE_ATTRIBUTE_DIRECTORY); + + } + + return false; +} + Error DirAccessWindows::rename(String p_path,String p_new_path) { p_path=fix_path(p_path); diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h index 926497c583..36530ba9b3 100644 --- a/drivers/windows/dir_access_windows.h +++ b/drivers/windows/dir_access_windows.h @@ -74,6 +74,7 @@ public: virtual bool file_exists(String p_file); + virtual bool dir_exists(String p_dir); virtual Error make_dir(String p_dir); |