From 8ae820cd4f12a7f5d6c3ffa7f9951721576e156c Mon Sep 17 00:00:00 2001 From: Pascal Nowack Date: Wed, 30 Dec 2020 02:17:43 +0100 Subject: [PATCH] winpr/clipboard: Also save lastWriteTime for FILEDESCRIPTORW Currently, when a local uri-list is converted into a FILEDESCRIPTORW list, WinPR doesn't submit the last write time for each file. The result of this is that the last write time of each file on the other peer will have the current time and not the actual last write time that is present on the peer, where the files were copied from. Fix this by also writing the last write time in addition to the FD_WRITESTIME flag. --- winpr/libwinpr/clipboard/posix.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/winpr/libwinpr/clipboard/posix.c b/winpr/libwinpr/clipboard/posix.c index 05052d90d..12c110fed 100644 --- a/winpr/libwinpr/clipboard/posix.c +++ b/winpr/libwinpr/clipboard/posix.c @@ -22,6 +22,7 @@ #endif #define _FILE_OFFSET_BITS 64 +#define WIN32_FILETIME_TO_UNIX_EPOCH UINT64_C(11644473600) #include #include @@ -52,6 +53,7 @@ struct posix_file char* local_name; WCHAR* remote_name; BOOL is_directory; + UINT64 last_write_time; int fd; INT64 offset; @@ -83,6 +85,7 @@ static struct posix_file* make_posix_file(const char* local_name, const WCHAR* r } file->is_directory = S_ISDIR(statbuf.st_mode); + file->last_write_time = (statbuf.st_mtime + WIN32_FILETIME_TO_UNIX_EPOCH) * 10 * 1000 * 1000; file->size = statbuf.st_size; return file; error: @@ -499,7 +502,7 @@ static BOOL convert_local_file_to_filedescriptor(const struct posix_file* file, FILEDESCRIPTORW* descriptor) { size_t remote_len = 0; - descriptor->dwFlags = FD_ATTRIBUTES | FD_FILESIZE | FD_PROGRESSUI; + descriptor->dwFlags = FD_ATTRIBUTES | FD_FILESIZE | FD_WRITESTIME | FD_PROGRESSUI; if (file->is_directory) { @@ -514,6 +517,9 @@ static BOOL convert_local_file_to_filedescriptor(const struct posix_file* file, descriptor->nFileSizeHigh = (file->size >> 32) & 0xFFFFFFFF; } + descriptor->ftLastWriteTime.dwLowDateTime = (file->last_write_time >> 0) & 0xFFFFFFFF; + descriptor->ftLastWriteTime.dwHighDateTime = (file->last_write_time >> 32) & 0xFFFFFFFF; + remote_len = _wcslen(file->remote_name); if (remote_len + 1 > ARRAYSIZE(descriptor->cFileName))