From 89da278bd94c1168e30f3debff0e0bdfdee9d47c Mon Sep 17 00:00:00 2001 From: Fear1ess <1256748979@qq.com> Date: Fri, 16 Apr 2021 16:36:16 +0800 Subject: [PATCH] 4/8 --- wandun/src/main/cpp/utils.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/wandun/src/main/cpp/utils.c b/wandun/src/main/cpp/utils.c index 16780f3..26960f5 100644 --- a/wandun/src/main/cpp/utils.c +++ b/wandun/src/main/cpp/utils.c @@ -13,6 +13,7 @@ #include "wd_syscall.h" #include "syscall.h" #include "fcntl.h" +#include "errno.h" IMPORTWDSYSCALL @@ -149,12 +150,9 @@ int read_file(const char *file_path, const char *mode, char *r_buf, size_t r_len } int is_file_exists(const char *file_path) { - int res; - int fd = WDSYSCALL(SYS_openat, AT_FDCWD, file_path, O_RDONLY, 0); - if(fd == -1) res = 0; - else { - WDSYSCALL(SYS_close, fd); - res = 1; - } - return res; + int fd = WDSYSCALL(SYS_faccessat, AT_FDCWD, file_path, R_OK, 0); + int err = errno; + if(fd == -1) return 0; + WDSYSCALL(SYS_close, fd); + return 1; } -- libgit2 0.27.1