From 38e669dbf55635fd715e3a782b39c9f0881eb601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 11 Feb 2018 00:35:56 +0100 Subject: NOISSUE change FS::updateTimestamp to work with directories too, use it to fix icon issues on macOS --- api/logic/FileSystem.cpp | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'api/logic') diff --git a/api/logic/FileSystem.cpp b/api/logic/FileSystem.cpp index 1f9f0e43..d24d9364 100644 --- a/api/logic/FileSystem.cpp +++ b/api/logic/FileSystem.cpp @@ -9,6 +9,14 @@ #include #include +#if defined Q_OS_WIN32 + #include + #include + #include +#else + #include +#endif + namespace FS { void ensureExists(const QDir &dir) @@ -62,21 +70,13 @@ QByteArray read(const QString &filename) bool updateTimestamp(const QString& filename) { - QFile file(filename); - if (!file.exists()) - { - return false; - } - if (!file.open(QIODevice::ReadWrite)) - { - return false; - } - const quint64 size = file.size(); - file.seek(size); - file.write( QByteArray(1, '0') ); - file.resize(size); - return true; - +#ifdef Q_OS_WIN32 + std::wstring filename_utf_16 = filename.toStdWString(); + return (_wutime64(filename_utf_16.c_str(), nullptr) == 0); +#else + QByteArray filenameBA = QFile::encodeName(filename); + return (utime(filenameBA.data(), nullptr) == 0); +#endif } bool ensureFilePathExists(QString filenamepath) @@ -163,11 +163,6 @@ bool copy::operator()(const QString &offset) return true; } - -#if defined Q_OS_WIN32 -#include -#include -#endif bool deletePath(QString path) { bool OK = true; -- cgit v1.2.3