# HG changeset patch # User Mike Becker # Date 1746096000 -7200 # Node ID 0b61e0164b445236789d8379e6d680f935e98d51 # Parent 029e839a4079c58d3d43a3aad13217ca9c32d8d2 implement system.h abstraction for utime() fixes #297 diff -r 029e839a4079 -r 0b61e0164b44 dav/sync.c --- a/dav/sync.c Thu May 01 01:16:53 2025 +0200 +++ b/dav/sync.c Thu May 01 12:40:00 2025 +0200 @@ -44,7 +44,6 @@ #ifndef _WIN32 // unix includes #include -#include #include #else //windows includes @@ -3634,21 +3633,16 @@ FileInfo f; finfo_get_values(fileinfo, &f); if((dir->metadata & FINFO_MTIME) == FINFO_MTIME && f.date_set) { - // TODO: implement on windows -#ifndef _WIN32 // set mtime - struct utimbuf t; + sys_utimbuf t; t.actime = f.last_modified; t.modtime = f.last_modified; - if(utime(path, &t)) { + if(sys_utime(path, &t)) { log_error("utime failed for file: %s : %s\n", path, strerror(errno)); ret = 1; } else { local->last_modified = f.last_modified; } -#else - local->last_modified = 0; -#endif } if((dir->metadata & FINFO_MODE) == FINFO_MODE && f.mode_set) { // set mode diff -r 029e839a4079 -r 0b61e0164b44 dav/system.c --- a/dav/system.c Thu May 01 01:16:53 2025 +0200 +++ b/dav/system.c Thu May 01 12:40:00 2025 +0200 @@ -528,4 +528,15 @@ return ret; } +int sys_utime(const char* filename, sys_utimbuf* times) { + wchar_t* wpath = path2winpath(filename, FALSE, NULL); + if (!wpath) { + fprintf(stderr, "sys_utime: cannot convert path\n"); + return -1; + } + int ret = _wutime(wpath, times); + free(wpath); + return ret; +} + #endif diff -r 029e839a4079 -r 0b61e0164b44 dav/system.h --- a/dav/system.h Thu May 01 01:16:53 2025 +0200 +++ b/dav/system.h Thu May 01 12:40:00 2025 +0200 @@ -36,11 +36,23 @@ #ifdef _WIN32 + #include #define mode_t unsigned int -#else + +#include +typedef struct _utimbuf sys_utimbuf; +int sys_utime(const char* filename, sys_utimbuf* times); + +#else // not _WIN32 + #include -#endif + +#include +typedef struct utimbuf sys_utimbuf; +#define sys_utime utime + +#endif // _WIN32 #ifdef __cplusplus extern "C" {