added exists() function
authorewt <devnull@localhost>
Wed, 13 Dec 1995 20:11:31 +0000 (20:11 +0000)
committerewt <devnull@localhost>
Wed, 13 Dec 1995 20:11:31 +0000 (20:11 +0000)
CVS patchset: 26
CVS date: 1995/12/13 20:11:31

lib/misc.c
lib/misc.h

index a08da13..737fca6 100644 (file)
@@ -1,4 +1,6 @@
+#include <errno.h>
 #include <stdlib.h>
+#include <sys/stat.h>
 
 #include "misc.h"
 
@@ -40,3 +42,17 @@ void freeSplitString(char ** list) {
     free(list[0]);
     free(list);
 }
+
+int exists(char * filespec) {
+    struct stat buf;
+
+    if (stat(filespec, &buf)) {
+       switch(errno) {
+          case ENOENT:
+          case EINVAL:
+               return 0;
+       }
+    }
+
+    return 1;
+}
index c82a9a9..444b3f8 100644 (file)
@@ -4,4 +4,6 @@
 char ** splitString(char * str, int length, char sep);
 void freeSplitString(char ** list);
 
+int exists(char * filespec);
+
 #endif