GH-347 update timestamps of added mods
This commit is contained in:
parent
b09fad9cbf
commit
9b41986634
@ -60,6 +60,25 @@ QByteArray read(const QString &filename)
|
|||||||
return data;
|
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)
|
bool ensureFilePathExists(QString filenamepath)
|
||||||
{
|
{
|
||||||
QFileInfo a(filenamepath);
|
QFileInfo a(filenamepath);
|
||||||
|
@ -28,6 +28,11 @@ MULTIMC_LOGIC_EXPORT void write(const QString &filename, const QByteArray &data)
|
|||||||
*/
|
*/
|
||||||
MULTIMC_LOGIC_EXPORT QByteArray read(const QString &filename);
|
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
|
* 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!
|
* last segment of the path is treated as a file name and is ignored!
|
||||||
|
@ -148,13 +148,13 @@ bool ModList::installMod(const QString &filename)
|
|||||||
QString newpath = FS::PathCombine(m_dir.path(), fileinfo.fileName());
|
QString newpath = FS::PathCombine(m_dir.path(), fileinfo.fileName());
|
||||||
if (!QFile::copy(fileinfo.filePath(), newpath))
|
if (!QFile::copy(fileinfo.filePath(), newpath))
|
||||||
return false;
|
return false;
|
||||||
|
FS::updateTimestamp(newpath);
|
||||||
m.repath(newpath);
|
m.repath(newpath);
|
||||||
update();
|
update();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (type == Mod::MOD_FOLDER)
|
else if (type == Mod::MOD_FOLDER)
|
||||||
{
|
{
|
||||||
|
|
||||||
QString from = fileinfo.filePath();
|
QString from = fileinfo.filePath();
|
||||||
QString to = FS::PathCombine(m_dir.path(), fileinfo.fileName());
|
QString to = FS::PathCombine(m_dir.path(), fileinfo.fileName());
|
||||||
if (!FS::copy(from, to)())
|
if (!FS::copy(from, to)())
|
||||||
|
Loading…
Reference in New Issue
Block a user