blob: 51f080ecc6d643ce1b3a1af240e62bdd48585733 [file] [log] [blame]
Shinichiro Hamaji776ca302015-06-06 03:52:48 +09001#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
10bool 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}