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

This commit is contained in:
Andrew Tonner 2020-02-12 16:28:00 -08:00
parent 837c82d8b8
commit 8b44b00da3
1 changed files with 10 additions and 1 deletions

View File

@ -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);