From f12f5173beceec77863949efa42d3f28093df457 Mon Sep 17 00:00:00 2001 From: asvitkine <> Date: Wed, 24 Jan 2007 02:37:06 +0000 Subject: [PATCH] macroman_to_host_encoding - so it works the other way around too --- BasiliskII/src/MacOSX/extfs_macosx.mm | 16 ++++++++++++++++ BasiliskII/src/Unix/extfs_unix.cpp | 8 ++++++++ BasiliskII/src/Windows/extfs_windows.cpp | 7 +++++++ BasiliskII/src/extfs.cpp | 2 +- BasiliskII/src/include/extfs.h | 1 + 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/BasiliskII/src/MacOSX/extfs_macosx.mm b/BasiliskII/src/MacOSX/extfs_macosx.mm index 022ea49f..47118c2e 100644 --- a/BasiliskII/src/MacOSX/extfs_macosx.mm +++ b/BasiliskII/src/MacOSX/extfs_macosx.mm @@ -438,3 +438,19 @@ const char *host_encoding_to_macroman(const char *filename) return filename; } + +// Convert from MacRoman to the host OS filename encoding +const char *macroman_to_host_encoding(const char *filename) +{ + static char filename_mr[64]; + CFStringRef sref = CFStringCreateWithCString(0, filename, kCFStringEncodingMacRoman); + if (sref) { + memset(filename_mr, 0, sizeof(filename_mr)); + if (CFStringGetCString(sref, filename_mr, sizeof(filename_mr), kCFStringEncodingUTF8)) { + return filename_mr; + } + CFRelease(sref); + } + return filename; +} + diff --git a/BasiliskII/src/Unix/extfs_unix.cpp b/BasiliskII/src/Unix/extfs_unix.cpp index fdcfd225..7182769d 100644 --- a/BasiliskII/src/Unix/extfs_unix.cpp +++ b/BasiliskII/src/Unix/extfs_unix.cpp @@ -382,3 +382,11 @@ const char *host_encoding_to_macroman(const char *filename) { return filename; } + +// Convert from MacRoman to host OS filename encoding +const char *macroman_to_host_encoding(const char *filename) +{ + return filename; +} + + diff --git a/BasiliskII/src/Windows/extfs_windows.cpp b/BasiliskII/src/Windows/extfs_windows.cpp index 3baf05ff..420fd5c7 100755 --- a/BasiliskII/src/Windows/extfs_windows.cpp +++ b/BasiliskII/src/Windows/extfs_windows.cpp @@ -390,3 +390,10 @@ const char *host_encoding_to_macroman(const char *filename) { return filename; } + +// Convert from MacRoman to host OS filename encoding +const char *macroman_to_host_encoding(const char *filename) +{ + return filename; +} + diff --git a/BasiliskII/src/extfs.cpp b/BasiliskII/src/extfs.cpp index e39ec892..dd3615a9 100644 --- a/BasiliskII/src/extfs.cpp +++ b/BasiliskII/src/extfs.cpp @@ -274,7 +274,7 @@ static FSItem *find_fsitem_guest(const char *guest_name, FSItem *parent) } // Not found, construct new FSItem - return create_fsitem(guest_name, guest_name, parent); + return create_fsitem(macroman_to_host_encoding(guest_name), guest_name, parent); } /* diff --git a/BasiliskII/src/include/extfs.h b/BasiliskII/src/include/extfs.h index a0f21284..006552b2 100644 --- a/BasiliskII/src/include/extfs.h +++ b/BasiliskII/src/include/extfs.h @@ -43,6 +43,7 @@ extern ssize_t extfs_write(int fd, void *buffer, size_t length); extern bool extfs_remove(const char *path); extern bool extfs_rename(const char *old_path, const char *new_path); extern const char *host_encoding_to_macroman(const char *filename); // What if the guest OS is using MacJapanese or MacArabic? Oh well... +extern const char *macroman_to_host_encoding(const char *filename); // What if the guest OS is using MacJapanese or MacArabic? Oh well... // Maximum length of full path name const int MAX_PATH_LENGTH = 1024;