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.

This commit is contained in:
Adam Ierymenko 2013-11-21 16:34:27 -05:00
parent 74af234305
commit b699bdefbd
3 changed files with 21 additions and 5 deletions

View file

@ -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;