mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-12-23 19:29:18 +00:00
Merge pull request #35 from rakslice/extfs_fixes
mingw32: Fix truncated extfs volume name, crash due to icon date issue
This commit is contained in:
commit
ef1569b4d1
@ -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);
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "sysdeps.h"
|
||||
#include "user_strings.h"
|
||||
|
||||
#include "util_windows.h"
|
||||
|
||||
// Platform-specific string definitions
|
||||
user_string_def platform_strings[] = {
|
||||
@ -81,7 +81,11 @@ static const char *get_volume_name(void)
|
||||
HKEY hHelpKey;
|
||||
DWORD key_type, cbData;
|
||||
|
||||
static char volume[256];
|
||||
#ifdef _UNICODE
|
||||
static char out_volume[256];
|
||||
#endif
|
||||
|
||||
static TCHAR volume[256];
|
||||
memset(volume, 0, sizeof(volume));
|
||||
|
||||
// Try Windows 2000 key first
|
||||
@ -118,14 +122,20 @@ static const char *get_volume_name(void)
|
||||
}
|
||||
|
||||
// Fix the error that some "tweak" apps do.
|
||||
if (_stricmp(volume, "%USERNAME% on %COMPUTER%") == 0)
|
||||
volume[0] = '\0';
|
||||
if (_tcsicmp(volume, TEXT("%USERNAME% on %COMPUTER%")) == 0)
|
||||
volume[0] = TEXT('\0');
|
||||
|
||||
// No volume name found, default to "My Computer"
|
||||
if (volume[0] == 0)
|
||||
strcpy(volume, "My Computer");
|
||||
_tcscpy(volume, TEXT("My Computer"));
|
||||
|
||||
|
||||
#ifdef _UNICODE
|
||||
strlcpy(out_volume, volume, 256);
|
||||
return out_volume;
|
||||
#else
|
||||
return volume;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,6 +133,13 @@ uint32 TimeToMacTime(time_t t)
|
||||
// This code is taken from glibc 2.2
|
||||
|
||||
// Convert to number of seconds elapsed since 1-Jan-1904
|
||||
|
||||
#ifdef WIN32
|
||||
if (t == -1) {
|
||||
// failsafe as this will segfault
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
struct tm *local = localtime(&t);
|
||||
const int TM_EPOCH_YEAR = 1900;
|
||||
const int MAC_EPOCH_YEAR = 1904;
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "sysdeps.h"
|
||||
#include "user_strings.h"
|
||||
|
||||
#include "util_windows.h"
|
||||
|
||||
// Platform-specific string definitions
|
||||
user_string_def platform_strings[] = {
|
||||
@ -86,7 +86,11 @@ static const char *get_volume_name(void)
|
||||
HKEY hHelpKey;
|
||||
DWORD key_type, cbData;
|
||||
|
||||
static char volume[256];
|
||||
#ifdef _UNICODE
|
||||
static char out_volume[256];
|
||||
#endif
|
||||
|
||||
static TCHAR volume[256];
|
||||
memset(volume, 0, sizeof(volume));
|
||||
|
||||
// Try Windows 2000 key first
|
||||
@ -123,14 +127,19 @@ static const char *get_volume_name(void)
|
||||
}
|
||||
|
||||
// Fix the error that some "tweak" apps do.
|
||||
if (stricmp(volume, "%USERNAME% on %COMPUTER%") == 0)
|
||||
volume[0] = '\0';
|
||||
if (_tcsicmp(volume, TEXT("%USERNAME% on %COMPUTER%")) == 0)
|
||||
volume[0] = TEXT('\0');
|
||||
|
||||
// No volume name found, default to "My Computer"
|
||||
if (volume[0] == 0)
|
||||
strcpy(volume, "My Computer");
|
||||
_tcscpy(volume, TEXT("My Computer"));
|
||||
|
||||
#ifdef _UNICODE
|
||||
strlcpy(out_volume, volume, 256);
|
||||
return out_volume;
|
||||
#else
|
||||
return volume;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,6 +327,10 @@ uint32 TimeToMacTime(time_t t)
|
||||
|
||||
// Convert to number of seconds elapsed since 1-Jan-1904
|
||||
#ifdef WIN32
|
||||
if (t == -1) {
|
||||
// failsafe as this will segfault
|
||||
return 0;
|
||||
}
|
||||
struct tm *local = localtime(&t);
|
||||
#else
|
||||
struct tm result;
|
||||
|
Loading…
Reference in New Issue
Block a user