diff --git a/BasiliskII/src/Windows/extfs_windows.cpp b/BasiliskII/src/Windows/extfs_windows.cpp index f2b8a372..76538129 100755 --- a/BasiliskII/src/Windows/extfs_windows.cpp +++ b/BasiliskII/src/Windows/extfs_windows.cpp @@ -269,6 +269,14 @@ void get_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) void set_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) { + struct my_utimbuf times; + times.actime = MacTimeToTime(ReadMacInt32(finfo - ioFlFndrInfo + ioFlCrDat)); + times.modtime = MacTimeToTime(ReadMacInt32(finfo - ioFlFndrInfo + ioFlMdDat)); + + if (utime(path, ×) < 0) { + D(bug("utime failed on %s, error %d\n", path, GetLastError())); + } + // Open Finder info file int fd = open_finf(path, O_RDWR); if (fd < 0) diff --git a/BasiliskII/src/Windows/posix_emu.cpp b/BasiliskII/src/Windows/posix_emu.cpp index 518a526f..26b99939 100755 --- a/BasiliskII/src/Windows/posix_emu.cpp +++ b/BasiliskII/src/Windows/posix_emu.cpp @@ -1123,3 +1123,28 @@ int my_write( int fd, const void *buffer, unsigned int count ) D(bug("write(%ld,%08x,%ld) = %d\n", fd, buffer, count, result)); return result; } + +FILETIME getFileTime(time_t time) { + FILETIME ft; + unsigned long long result = 11644473600LL; + result += time; + result *= 10000000LL; + ft.dwHighDateTime = (result >> 32); + ft.dwLowDateTime = (result & 0xFFFFFFFF); + return ft; +} + +int my_utime( const char *path, struct my_utimbuf * my_times ) +{ + auto tpath = tstr(path); + LPCTSTR p = MRP(tpath.get()); + HANDLE f = CreateFile(p, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (f != INVALID_HANDLE_VALUE) { + FILETIME crTime = getFileTime(my_times->actime); + FILETIME modTime = getFileTime(my_times->modtime); + SetFileTime(f, &crTime, NULL, &modTime); + CloseHandle(f); + return 0; + } + return -1; +} diff --git a/BasiliskII/src/Windows/posix_emu.h b/BasiliskII/src/Windows/posix_emu.h index f5077558..730d63df 100755 --- a/BasiliskII/src/Windows/posix_emu.h +++ b/BasiliskII/src/Windows/posix_emu.h @@ -73,6 +73,7 @@ int my_read( int fd, void *, unsigned int); int my_write( int fd, const void *, unsigned int); int my_chsize( int fd, unsigned int size ); int my_locking( int fd, int mode, long nbytes ); +int my_utime( const char *path, struct my_utimbuf * ); extern int my_errno; @@ -92,6 +93,7 @@ extern int my_errno; #define write my_write #define ftruncate my_chsize #define locking my_locking +#define utime my_utime #undef errno #define errno my_errno @@ -116,6 +118,12 @@ struct my_stat { time_t st_ctime; }; +struct my_utimbuf +{ + time_t actime; // access time + time_t modtime; // modification time +}; + // Your compiler may have different "struct stat" -> edit "struct my_stat" #define validate_stat_struct ( sizeof(struct my_stat) == sizeof(struct stat) )