summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-09-05 01:18:53 +0200
committerGitHub <noreply@github.com>2017-09-05 01:18:53 +0200
commit44adf75cd53c22f146fc2e2dbba7d7efab3c0a0d (patch)
tree8b3bf1fb6edb9046b9e916eff2786f102acde6f1 /drivers
parent27feafbe126cbc39fbb1a44a70b62bbfa8b8fa73 (diff)
parent5fed954a1b16c616f650f0b58c8647bcda5606e7 (diff)
Merge pull request #10986 from hpvb/fix-unix-file-open
Fix UNIX file open
Diffstat (limited to 'drivers')
-rw-r--r--drivers/unix/file_access_unix.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index ec97826a12..db06cce644 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -91,15 +91,14 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
//printf("opening %s as %s\n", p_path.utf8().get_data(), path.utf8().get_data());
struct stat st;
int err = stat(path.utf8().get_data(), &st);
- if (err)
- return ERR_FILE_CANT_OPEN;
-
- switch (st.st_mode & S_IFMT) {
- case S_IFLNK:
- case S_IFREG:
- break;
- default:
- return ERR_FILE_CANT_OPEN;
+ if (!err) {
+ switch (st.st_mode & S_IFMT) {
+ case S_IFLNK:
+ case S_IFREG:
+ break;
+ default:
+ return ERR_FILE_CANT_OPEN;
+ }
}
if (is_backup_save_enabled() && (p_mode_flags & WRITE) && !(p_mode_flags & READ)) {