NOISSUE change FS::updateTimestamp to work with directories too, use it to fix icon issues on macOS
This commit is contained in:
parent
ca11765436
commit
38e669dbf5
@ -9,6 +9,14 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
#if defined Q_OS_WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#include <string>
|
||||||
|
#include <sys/utime.h>
|
||||||
|
#else
|
||||||
|
#include <utime.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace FS {
|
namespace FS {
|
||||||
|
|
||||||
void ensureExists(const QDir &dir)
|
void ensureExists(const QDir &dir)
|
||||||
@ -62,21 +70,13 @@ QByteArray read(const QString &filename)
|
|||||||
|
|
||||||
bool updateTimestamp(const QString& filename)
|
bool updateTimestamp(const QString& filename)
|
||||||
{
|
{
|
||||||
QFile file(filename);
|
#ifdef Q_OS_WIN32
|
||||||
if (!file.exists())
|
std::wstring filename_utf_16 = filename.toStdWString();
|
||||||
{
|
return (_wutime64(filename_utf_16.c_str(), nullptr) == 0);
|
||||||
return false;
|
#else
|
||||||
}
|
QByteArray filenameBA = QFile::encodeName(filename);
|
||||||
if (!file.open(QIODevice::ReadWrite))
|
return (utime(filenameBA.data(), nullptr) == 0);
|
||||||
{
|
#endif
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const quint64 size = file.size();
|
|
||||||
file.seek(size);
|
|
||||||
file.write( QByteArray(1, '0') );
|
|
||||||
file.resize(size);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ensureFilePathExists(QString filenamepath)
|
bool ensureFilePathExists(QString filenamepath)
|
||||||
@ -163,11 +163,6 @@ bool copy::operator()(const QString &offset)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined Q_OS_WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#include <string>
|
|
||||||
#endif
|
|
||||||
bool deletePath(QString path)
|
bool deletePath(QString path)
|
||||||
{
|
{
|
||||||
bool OK = true;
|
bool OK = true;
|
||||||
|
@ -330,6 +330,8 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
QDir foo(FS::PathCombine(binPath, "../.."));
|
QDir foo(FS::PathCombine(binPath, "../.."));
|
||||||
m_rootPath = foo.absolutePath();
|
m_rootPath = foo.absolutePath();
|
||||||
|
// on macOS, touch the root to force Finder to reload the .app metadata (and fix any icon change issues)
|
||||||
|
FS::updateTimestamp(m_rootPath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MULTIMC_JARS_LOCATION
|
#ifdef MULTIMC_JARS_LOCATION
|
||||||
|
Loading…
Reference in New Issue
Block a user