Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 1 | #include "fileutil.h" |
2 | |||||
3 | #include <errno.h> | ||||
4 | #include <limits.h> | ||||
5 | #include <sys/stat.h> | ||||
6 | #include <unistd.h> | ||||
7 | |||||
8 | #include "log.h" | ||||
9 | |||||
10 | bool Exists(StringPiece filename) { | ||||
11 | CHECK(filename.size() < PATH_MAX); | ||||
12 | char buf[PATH_MAX+1]; | ||||
13 | memcpy(buf, filename.data(), filename.size()); | ||||
14 | buf[filename.size()] = 0; | ||||
15 | struct stat st; | ||||
16 | if (stat(buf, &st) < 0) { | ||||
17 | return false; | ||||
18 | } | ||||
19 | return true; | ||||
20 | } |