diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-11-21 16:34:27 -0500 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-11-21 16:34:27 -0500 |
| commit | b699bdefbd008a5dbfab4308e9b969b2aaa88ce1 (patch) | |
| tree | ffcdbca9f667f72fd195d3087d7886db39505ad2 /node/Utils.cpp | |
| parent | 74af234305a3758589112212b4c270756fa73243 (diff) | |
| download | infinitytier-b699bdefbd008a5dbfab4308e9b969b2aaa88ce1.tar.gz infinitytier-b699bdefbd008a5dbfab4308e9b969b2aaa88ce1.zip | |
Add shutdownIfUnreadable file feature: shut down if shutdownIfUnreadable in home folder is in fact existent but unreadable (e.g. broken link). This enables nifty shutdown on .app trashing feature for OSX.
Diffstat (limited to 'node/Utils.cpp')
| -rw-r--r-- | node/Utils.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/node/Utils.cpp b/node/Utils.cpp index 31cb40dd..608de593 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -246,7 +246,7 @@ no getSecureRandom() implementation; void Utils::lockDownFile(const char *path,bool isDir) { -#if defined(__APPLE__) || defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux) +#ifdef __UNIX_LIKE__ chmod(path,isDir ? 0700 : 0600); #else #ifdef _WIN32 @@ -263,6 +263,16 @@ uint64_t Utils::getLastModified(const char *path) return (((uint64_t)s.st_mtime) * 1000ULL); } +bool Utils::fileExists(const char *path,bool followLinks) +{ + struct stat s; +#ifdef __UNIX_LIKE__ + if (!followLinks) + return (lstat(path,&s) == 0); +#endif + return (stat(path,&s) == 0); +} + int64_t Utils::getFileSize(const char *path) { struct stat s; |
