Mercurial > trustbridge
diff common/portpath.c @ 168:f100861dad8f
Added simple portable function to test if an file exists.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 25 Mar 2014 13:08:59 +0100 |
parents | 199878f09bf1 |
children | 701b7036c5dc |
line wrap: on
line diff
--- a/common/portpath.c Tue Mar 25 12:54:47 2014 +0100 +++ b/common/portpath.c Tue Mar 25 13:08:59 2014 +0100 @@ -4,6 +4,9 @@ #include <limits.h> #include <stdio.h> #include <stdlib.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> char * @@ -31,3 +34,21 @@ return _fullpath(NULL, path, 0); #endif } + +bool +port_fileexits(char *path) +{ + int ret; +#ifndef _WIN32 + struct stat sb; + ret = stat(path, &sb); +#else + struct _stat sb; + ret = _stat(path, &sb); +#endif + + if (ret == 0) + return true; + else + return false; +}