mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-23 01:38:11 +02:00
parent
f6db26f683
commit
71e19c4d01
@ -1306,6 +1306,26 @@ bool Utility::PathExists(const String& path)
|
|||||||
return fs::exists(fs::path(path.Begin(), path.End()), ec) && !ec;
|
return fs::exists(fs::path(path.Begin(), path.End()), ec) && !ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Utility::GetModTime(const String& path)
|
||||||
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
|
if (stat(path.CStr(), &statbuf) < 0) {
|
||||||
|
#else /* _WIN32 */
|
||||||
|
struct _stat statbuf;
|
||||||
|
|
||||||
|
if (_stat(path.CStr(), &statbuf) < 0) {
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
BOOST_THROW_EXCEPTION(posix_error()
|
||||||
|
<< boost::errinfo_api_function("stat")
|
||||||
|
<< boost::errinfo_errno(errno)
|
||||||
|
<< boost::errinfo_file_name(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
return statbuf.st_mtime;
|
||||||
|
}
|
||||||
|
|
||||||
Value Utility::LoadJsonFile(const String& path)
|
Value Utility::LoadJsonFile(const String& path)
|
||||||
{
|
{
|
||||||
std::ifstream fp;
|
std::ifstream fp;
|
||||||
|
@ -111,6 +111,7 @@ public:
|
|||||||
static tm LocalTime(time_t ts);
|
static tm LocalTime(time_t ts);
|
||||||
|
|
||||||
static bool PathExists(const String& path);
|
static bool PathExists(const String& path);
|
||||||
|
static double GetModTime(const String& path);
|
||||||
|
|
||||||
static void Remove(const String& path);
|
static void Remove(const String& path);
|
||||||
static void RemoveDirRecursive(const String& path);
|
static void RemoveDirRecursive(const String& path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user