mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Fixed: Wrong modification dates of files uncompressed from 7z and ZIP archives
This commit is contained in:
parent
c2d74a55e0
commit
2cb2a92e7a
1 changed files with 40 additions and 0 deletions
|
@ -291,6 +291,26 @@ bool CFilesExtractor::exec()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32 convertWindowsFileTimeToUnixTimestamp(const CNtfsFileTime &nt)
|
||||||
|
{
|
||||||
|
// first, convert it into second since jan1, 1601
|
||||||
|
uint64 t = nt.Low | (uint64(nt.High) << 32);
|
||||||
|
|
||||||
|
// offset to convert Windows file times to UNIX timestamp
|
||||||
|
uint64 offset = UINT64_CONSTANT(116444736000000000);
|
||||||
|
|
||||||
|
// adjust time base to unix epoch base
|
||||||
|
t -= offset;
|
||||||
|
|
||||||
|
// convert the resulting time into seconds
|
||||||
|
t /= 10; // microsec
|
||||||
|
t /= 1000; // millisec
|
||||||
|
t /= 1000; // sec
|
||||||
|
|
||||||
|
// return the resulting time
|
||||||
|
return uint32(t);
|
||||||
|
}
|
||||||
|
|
||||||
bool CFilesExtractor::extract7z()
|
bool CFilesExtractor::extract7z()
|
||||||
{
|
{
|
||||||
Q7zFile inFile(m_sourceFile);
|
Q7zFile inFile(m_sourceFile);
|
||||||
|
@ -432,10 +452,24 @@ bool CFilesExtractor::extract7z()
|
||||||
|
|
||||||
if (m_listener) m_listener->operationProgress(totalUncompressed, filename);
|
if (m_listener) m_listener->operationProgress(totalUncompressed, filename);
|
||||||
|
|
||||||
|
// set attrinbutes
|
||||||
if (SzBitWithVals_Check(&db.Attribs, i))
|
if (SzBitWithVals_Check(&db.Attribs, i))
|
||||||
|
{
|
||||||
Set7zFileAttrib(destPath, db.Attribs.Vals[i]);
|
Set7zFileAttrib(destPath, db.Attribs.Vals[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set modification time
|
||||||
|
if (SzBitWithVals_Check(&db.MTime, i))
|
||||||
|
{
|
||||||
|
char buffer[1024];
|
||||||
|
|
||||||
|
if (!NLMISC::CFile::setFileModificationDate(qToUtf8(destPath), convertWindowsFileTimeToUnixTimestamp(db.MTime.Vals[i])))
|
||||||
|
{
|
||||||
|
qDebug() << "Unable to change date of " << destPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IAlloc_Free(&allocImp, outBuffer);
|
IAlloc_Free(&allocImp, outBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,6 +584,12 @@ bool CFilesExtractor::extractZip()
|
||||||
f.setPermissions(fi.permissions);
|
f.setPermissions(fi.permissions);
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
|
// set the right modification date
|
||||||
|
if (!NLMISC::CFile::setFileModificationDate(qToUtf8(absPath), fi.lastModified.toTime_t()))
|
||||||
|
{
|
||||||
|
qDebug() << "Unable to change date of " << absPath;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_listener) m_listener->operationProgress(currentSize, QFileInfo(absPath).fileName());
|
if (m_listener) m_listener->operationProgress(currentSize, QFileInfo(absPath).fileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue