summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-08-21 08:54:32 +0200
committerGitHub <noreply@github.com>2019-08-21 08:54:32 +0200
commit7b37321ae3996b8660f18ae8b2b630e9c1940621 (patch)
tree8c7c5bed7ad8cee04995c48a9206f2269ff049ae /drivers
parent093798c976373a664a8e274ae31774e8dcf2238a (diff)
parentb49226e0850d6dd30801881433bf3fef1f1608b1 (diff)
Merge pull request #31499 from nekomatata/fix-new-project-metadata
Setting project metadata doesn't fail when project_metadata.cfg doesn't exist
Diffstat (limited to 'drivers')
-rw-r--r--drivers/unix/file_access_unix.cpp13
-rw-r--r--drivers/windows/file_access_windows.cpp13
2 files changed, 21 insertions, 5 deletions
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index 5820a59019..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;
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index c12a2d75a8..7db847d6ed 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -114,11 +114,18 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
path = path + ".tmp";
}
- _wfopen_s(&f, path.c_str(), mode_string);
+ errno_t errcode = _wfopen_s(&f, path.c_str(), mode_string);
if (f == NULL) {
- last_error = ERR_FILE_CANT_OPEN;
- return ERR_FILE_CANT_OPEN;
+ switch (errcode) {
+ 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;