From e7f3fbad7c1afdb22542d2ff0b89d9d3d71282f0 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sun, 29 Oct 2000 01:15:58 +0000 Subject: [PATCH] Added cmartin's Unix/GNU libc support mods. --- src/sbbs3/wrappers.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/sbbs3/wrappers.c b/src/sbbs3/wrappers.c index 32bcdf7cf1..770d7353bf 100644 --- a/src/sbbs3/wrappers.c +++ b/src/sbbs3/wrappers.c @@ -47,6 +47,12 @@ #include <ctype.h> /* toupper */ #include <sys/kd.h> /* KIOCSOUND */ #include <sys/ioctl.h> /* ioctl */ +#include <glob.h> /* glob() wildcard matching */ +#include <string.h> /* strlen() */ + +#ifdef __GLIBC__ /* actually, BSD, but will work for now */ +#include <sys/vfs.h> /* statfs() */ +#endif #endif @@ -89,6 +95,34 @@ BOOL DLLCALL fexist(char *filespec) return(TRUE); +#elif defined(__unix__) /* portion by cmartin */ + + glob_t *aglob; + int c; + int l; + + // start the search + glob(filespec, GLOB_MARK | GLOB_NOSORT, NULL, aglob); + + if (!aglob->gl_pathc) { + // no results + globfree(aglob); + return FALSE; + } + + // make sure it's not a directory + c = aglob->gl_pathc; + while (c--) { + l = strlen(aglob->gl_pathv[c]); + if (aglob->gl_pathv[c][l] != '/') { + globfree(aglob); + return TRUE; + } + } + + globfree(aglob); + return FALSE; + #else #warning "fexist() port needs to support wildcards!" @@ -316,8 +350,20 @@ ulong DLLCALL getfreediskspace(char* path) return(0); return(NumberOfFreeClusters*SectorsPerCluster*BytesPerSector); + +#elif defined(__GLIBC__) + + struct statfs fs; + + if (statfs(path, &fs) < 0) + return 0; + + return fs.f_bsize * fs.f_bavail; + #else + #warning OS-specific code needed here return(0); + #endif } -- GitLab