Add os_file_exists()

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2013-03-28 10:38:17 +02:00 committed by Jouni Malinen
parent 1cb3eda954
commit d2bb2b4681
2 changed files with 17 additions and 0 deletions

View file

@ -239,6 +239,13 @@ int os_unsetenv(const char *name);
*/ */
char * os_readfile(const char *name, size_t *len); char * os_readfile(const char *name, size_t *len);
/**
* os_file_exists - Check whether the specified file exists
* @fname: Path and name of the file
* Returns: 1 if the file exists or 0 if not
*/
int os_file_exists(const char *fname);
/** /**
* os_zalloc - Allocate and zero memory * os_zalloc - Allocate and zero memory
* @size: Number of bytes to allocate * @size: Number of bytes to allocate

View file

@ -407,6 +407,16 @@ 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;
}
#ifndef WPA_TRACE #ifndef WPA_TRACE
void * os_zalloc(size_t size) void * os_zalloc(size_t size)
{ {