Mercurial > trustbridge
comparison 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 |
comparison
equal
deleted
inserted
replaced
167:92d7e0b40808 | 168:f100861dad8f |
---|---|
2 | 2 |
3 #include <libgen.h> | 3 #include <libgen.h> |
4 #include <limits.h> | 4 #include <limits.h> |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <sys/stat.h> | |
8 #include <sys/types.h> | |
9 #include <unistd.h> | |
7 | 10 |
8 | 11 |
9 char * | 12 char * |
10 port_dirname(char *path) | 13 port_dirname(char *path) |
11 { | 14 { |
29 return realpath(path, NULL); | 32 return realpath(path, NULL); |
30 #else | 33 #else |
31 return _fullpath(NULL, path, 0); | 34 return _fullpath(NULL, path, 0); |
32 #endif | 35 #endif |
33 } | 36 } |
37 | |
38 bool | |
39 port_fileexits(char *path) | |
40 { | |
41 int ret; | |
42 #ifndef _WIN32 | |
43 struct stat sb; | |
44 ret = stat(path, &sb); | |
45 #else | |
46 struct _stat sb; | |
47 ret = _stat(path, &sb); | |
48 #endif | |
49 | |
50 if (ret == 0) | |
51 return true; | |
52 else | |
53 return false; | |
54 } |