projects
/
mech_eap.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
cfe0a01
)
utils: os_unix: Use access() for checking file existence
author
Rahul Bedarkar
<rahulbedarkar89@gmail.com>
Wed, 27 Jul 2016 16:47:53 +0000
(22:17 +0530)
committer
Jouni Malinen
<j@w1.fi>
Sun, 7 Aug 2016 21:24:07 +0000
(
00:24
+0300)
Trying to open file for checking file existence seems to be too much.
Instead use access system call which is meant for the same.
Signed-off-by: Rahul Bedarkar <rahulbedarkar89@gmail.com>
src/utils/os_unix.c
patch
|
blob
|
history
diff --git
a/src/utils/os_unix.c
b/src/utils/os_unix.c
index
0118d98
..
65c6fa4
100644
(file)
--- a/
src/utils/os_unix.c
+++ b/
src/utils/os_unix.c
@@
-435,11
+435,7
@@
char * os_readfile(const char *name, size_t *len)
int os_file_exists(const char *fname)
{
- FILE *f = fopen(fname, "rb");
- if (f == NULL)
- return 0;
- fclose(f);
- return 1;
+ return access(fname, F_OK) == 0;
}