Commit 89da278b by Fear1ess

4/8

parent a907e0e0
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment