summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-11-17 04:09:24 +0100
committerPetr Mrázek <peterix@gmail.com>2016-11-17 04:09:24 +0100
commit9b4198663463ce584fbd4f78adff29edc2bbc51c (patch)
treeaa2efabf194ef68bc454582ee497acc38bbb1dc9 /api
parentb09fad9cbf1f297ba2abb852d683f9fe5cfb9b3b (diff)
downloadMultiMC-9b4198663463ce584fbd4f78adff29edc2bbc51c.tar
MultiMC-9b4198663463ce584fbd4f78adff29edc2bbc51c.tar.gz
MultiMC-9b4198663463ce584fbd4f78adff29edc2bbc51c.tar.lz
MultiMC-9b4198663463ce584fbd4f78adff29edc2bbc51c.tar.xz
MultiMC-9b4198663463ce584fbd4f78adff29edc2bbc51c.zip
GH-347 update timestamps of added mods
Diffstat (limited to 'api')
-rw-r--r--api/logic/FileSystem.cpp19
-rw-r--r--api/logic/FileSystem.h5
-rw-r--r--api/logic/minecraft/ModList.cpp2
3 files changed, 25 insertions, 1 deletions
diff --git a/api/logic/FileSystem.cpp b/api/logic/FileSystem.cpp
index 7805a78b..67bafd28 100644
--- a/api/logic/FileSystem.cpp
+++ b/api/logic/FileSystem.cpp
@@ -60,6 +60,25 @@ QByteArray read(const QString &filename)
return data;
}
+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;
+
+}
+
bool ensureFilePathExists(QString filenamepath)
{
QFileInfo a(filenamepath);
diff --git a/api/logic/FileSystem.h b/api/logic/FileSystem.h
index 564f94f9..a09ee557 100644
--- a/api/logic/FileSystem.h
+++ b/api/logic/FileSystem.h
@@ -29,6 +29,11 @@ MULTIMC_LOGIC_EXPORT void write(const QString &filename, const QByteArray &data)
MULTIMC_LOGIC_EXPORT QByteArray read(const QString &filename);
/**
+ * Update the last changed timestamp of an existing file
+ */
+MULTIMC_LOGIC_EXPORT bool updateTimestamp(const QString & filename);
+
+/**
* Creates all the folders in a path for the specified path
* last segment of the path is treated as a file name and is ignored!
*/
diff --git a/api/logic/minecraft/ModList.cpp b/api/logic/minecraft/ModList.cpp
index 7396cd65..10a145b8 100644
--- a/api/logic/minecraft/ModList.cpp
+++ b/api/logic/minecraft/ModList.cpp
@@ -148,13 +148,13 @@ bool ModList::installMod(const QString &filename)
QString newpath = FS::PathCombine(m_dir.path(), fileinfo.fileName());
if (!QFile::copy(fileinfo.filePath(), newpath))
return false;
+ FS::updateTimestamp(newpath);
m.repath(newpath);
update();
return true;
}
else if (type == Mod::MOD_FOLDER)
{
-
QString from = fileinfo.filePath();
QString to = FS::PathCombine(m_dir.path(), fileinfo.fileName());
if (!FS::copy(from, to)())