added exists() function

CVS patchset: 26
CVS date: 1995/12/13 20:11:31
This commit is contained in:
ewt 1995-12-13 20:11:31 +00:00
parent 1fa608da50
commit 958dc058a4
2 changed files with 18 additions and 0 deletions

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

View File

@ -4,4 +4,6 @@
char ** splitString(char * str, int length, char sep);
void freeSplitString(char ** list);
int exists(char * filespec);
#endif