added exists() function
CVS patchset: 26 CVS date: 1995/12/13 20:11:31
This commit is contained in:
parent
1fa608da50
commit
958dc058a4
16
lib/misc.c
16
lib/misc.c
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -4,4 +4,6 @@
|
|||
char ** splitString(char * str, int length, char sep);
|
||||
void freeSplitString(char ** list);
|
||||
|
||||
int exists(char * filespec);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue