#include <QObject>
#include <windows.h>
#include <qfile.h>
#include <qtextstream.h>
#include <iostream>
#include <qdir>
#include <QString>
// file copy operation that preserves file timestamps
QFile sourceFile
(srcFile
);
FILETIME ftCreate, ftAccess, ftWrite;
return false;
return false;
destFile.write(sourceFile.readAll());
sourceFile.close();
destFile.close();
wchar_t *srcPath = new wchar_t[srcFile.length()];
for (int i(0);i<srcFile.length();i++) {
srcPath[i] = srcFile.toStdString().c_str()[i];
}
wchar_t *dstPath = new wchar_t[dstFile.length()];
for (int x(0);x<dstFile.length();x++) {
dstPath[x] = dstFile.toStdString().c_str()[x];
}
HANDLE sfile = CreateFile(srcPath,0,0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_READONLY,NULL);
HANDLE dfile = CreateFile(dstPath,GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
GetFileTime(sfile,&ftCreate, &ftAccess, &ftWrite);
SetFileTime(dfile,&ftCreate, &ftAccess, &ftWrite);
CloseHandle(sfile);
CloseHandle(dfile);
delete [] srcPath;
delete [] dstPath;
return true;
}
#include <QObject>
#include <windows.h>
#include <qfile.h>
#include <qtextstream.h>
#include <iostream>
#include <qdir>
#include <QString>
// file copy operation that preserves file timestamps
bool copyFile(QString srcFile,QString dstFile) {
QFile sourceFile(srcFile);
FILETIME ftCreate, ftAccess, ftWrite;
if (!sourceFile.open(QIODevice::ReadOnly))
return false;
QFile destFile(dstFile);
if (!destFile.open(QIODevice::WriteOnly))
return false;
destFile.write(sourceFile.readAll());
sourceFile.close();
destFile.close();
wchar_t *srcPath = new wchar_t[srcFile.length()];
for (int i(0);i<srcFile.length();i++) {
srcPath[i] = srcFile.toStdString().c_str()[i];
}
wchar_t *dstPath = new wchar_t[dstFile.length()];
for (int x(0);x<dstFile.length();x++) {
dstPath[x] = dstFile.toStdString().c_str()[x];
}
HANDLE sfile = CreateFile(srcPath,0,0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_READONLY,NULL);
HANDLE dfile = CreateFile(dstPath,GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
GetFileTime(sfile,&ftCreate, &ftAccess, &ftWrite);
SetFileTime(dfile,&ftCreate, &ftAccess, &ftWrite);
CloseHandle(sfile);
CloseHandle(dfile);
delete [] srcPath;
delete [] dstPath;
return true;
}
To copy to clipboard, switch view to plain text mode
Bookmarks