Removed implicit conversion from std::filesystem::file_time_type since it is broken in GCC9, fixes #7

This commit is contained in:
emeric
2019-10-28 20:04:19 +01:00
parent d261b6a651
commit 512dae2ad9
4 changed files with 37 additions and 5 deletions
+19 -2
View File
@@ -19,6 +19,10 @@
#include "Path.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <array>
#include <fstream>
@@ -28,7 +32,8 @@
#include "utils/Exception.hpp"
#include "utils/Logger.hpp"
void computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& crc)
void
computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& crc)
{
using crc_type = boost::crc_32_type;
crc_type result;
@@ -62,7 +67,8 @@ void computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& crc)
}
}
bool ensureDirectory(const std::filesystem::path& dir)
bool
ensureDirectory(const std::filesystem::path& dir)
{
if (std::filesystem::exists(dir))
return std::filesystem::is_directory(dir);
@@ -70,3 +76,14 @@ bool ensureDirectory(const std::filesystem::path& dir)
return std::filesystem::create_directory(dir);
}
std::time_t
getLastWriteTime(const std::filesystem::path& file)
{
struct stat sb {};
if (stat(file.string().c_str(), &sb) == -1)
throw LmsException("Failed to get stats on file '" + file.string() + "'" );
return sb.st_mtime;
}