forked from qt-creator/qt-creator
Trk: Setting correct date and time when closing remote file.
Reviewed-by: Friedemann Kleint
This commit is contained in:
@@ -467,7 +467,7 @@ void Launcher::closeRemoteFile(bool failed)
|
||||
{
|
||||
QByteArray ba;
|
||||
appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder);
|
||||
appendInt(&ba, QDateTime::currentDateTime().toTime_t(), TargetByteOrder);
|
||||
appendDateTime(&ba, QDateTime::currentDateTime(), TargetByteOrder);
|
||||
d->m_device->sendTrkMessage(TrkCloseFile,
|
||||
failed ? TrkCallback() : TrkCallback(this, &Launcher::handleFileCopied),
|
||||
ba);
|
||||
|
@@ -32,6 +32,9 @@
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QDate>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QTime>
|
||||
|
||||
#define logMessage(s) do { qDebug() << "TRKCLIENT: " << s; } while (0)
|
||||
|
||||
@@ -400,6 +403,18 @@ void appendString(QByteArray *ba, const QByteArray &str, Endianness endian, bool
|
||||
ba->append('\0');
|
||||
}
|
||||
|
||||
void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness endian)
|
||||
{
|
||||
// convert the QDateTime to UTC and append its representation to QByteArray
|
||||
// format is the same as in FAT file system
|
||||
dateTime = dateTime.toUTC();
|
||||
const QTime utcTime = dateTime.time();
|
||||
const QDate utcDate = dateTime.date();
|
||||
uint fatDateTime = (utcTime.hour() << 11 | utcTime.minute() << 5 | utcTime.second()/2) << 16;
|
||||
fatDateTime |= (utcDate.year()-1980) << 9 | utcDate.month() << 5 | utcDate.day();
|
||||
appendInt(ba, fatDateTime, endian);
|
||||
}
|
||||
|
||||
QByteArray errorMessage(byte code)
|
||||
{
|
||||
switch (code) {
|
||||
|
@@ -37,6 +37,8 @@
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
class QDateTime;
|
||||
|
||||
namespace trk {
|
||||
|
||||
enum Command {
|
||||
@@ -92,6 +94,7 @@ void appendByte(QByteArray *ba, byte b);
|
||||
void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder);
|
||||
void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder);
|
||||
void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder, bool appendNullTerminator = true);
|
||||
void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness = TargetByteOrder);
|
||||
|
||||
struct Library
|
||||
{
|
||||
|
Reference in New Issue
Block a user