utils: os_unix: Use access() for checking file existence

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>
This commit is contained in:
Rahul Bedarkar 2016-07-27 22:17:53 +05:30 committed by Jouni Malinen
parent cfe0a0194b
commit a2072a29b9

View file

@ -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;
}