From 8b44b00da3449164e9a5409ae45223ec989253b7 Mon Sep 17 00:00:00 2001 From: Andrew Tonner Date: Wed, 12 Feb 2020 16:28:00 -0800 Subject: [PATCH] In extfs icon creation, ensure that the times on the host file are set correctly; actually allocate space for the other HInfo that set_finfo reads, such as the times --- BasiliskII/src/Windows/posix_emu.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/BasiliskII/src/Windows/posix_emu.cpp b/BasiliskII/src/Windows/posix_emu.cpp index 8d671abc..c93b2e09 100755 --- a/BasiliskII/src/Windows/posix_emu.cpp +++ b/BasiliskII/src/Windows/posix_emu.cpp @@ -392,14 +392,23 @@ void init_posix_emu(void) int fd = my_creat( custom_icon_name, 0 ); if(fd >= 0) { my_close(fd); + struct my_stat custom_icon_stat; + int stat_result = my_stat( custom_icon_name, &custom_icon_stat ); fd = open_rfork( custom_icon_name, O_RDWR|O_CREAT ); if(fd >= 0) { my_write( fd, my_comp_icon, sizeof(my_comp_icon) ); my_close(fd); - static uint8 host_finfo[SIZEOF_FInfo]; + // need room for the things from around the finfo that set_finfo reads + static uint8 custom_icon_hfile[ioFlXFndrInfo + SIZEOF_FXInfo]; + memset(custom_icon_hfile, 0, ioFlXFndrInfo + SIZEOF_FXInfo); + static uint8 * host_finfo = custom_icon_hfile + ioFlFndrInfo; uint32 finfo = Host2MacAddr(host_finfo); get_finfo(custom_icon_name, finfo, 0, false); WriteMacInt16(finfo + fdFlags, kIsInvisible); + if (stat_result == 0) { + WriteMacInt32(finfo - ioFlFndrInfo + ioFlCrDat, TimeToMacTime(custom_icon_stat.st_ctime)); + WriteMacInt32(finfo - ioFlFndrInfo + ioFlMdDat, TimeToMacTime(custom_icon_stat.st_mtime)); + } set_finfo(custom_icon_name, finfo, 0, false); get_finfo(my_computer, finfo, 0, true); WriteMacInt16(finfo + fdFlags, ReadMacInt16(finfo + fdFlags) | kHasCustomIcon);