]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add os_file_exists()
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 28 Mar 2013 08:38:17 +0000 (10:38 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 11 Mar 2014 23:09:22 +0000 (01:09 +0200)
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/utils/os.h
src/utils/os_unix.c

index d63ac294b2bc9cec6b8ddefcd59dd234a0261a9e..f019e26b13683098d6be9a7ebd8ba1015aeb2157 100644 (file)
@@ -239,6 +239,13 @@ int os_unsetenv(const char *name);
  */
 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
  * @size: Number of bytes to allocate
index fa67fdfb6869ec24dcfae8c98631d0e1fdffac00..008ec6b0846e926778eb988176d548a757e62324 100644 (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
 void * os_zalloc(size_t size)
 {