macroman_to_host_encoding - so it works the other way around too

This commit is contained in:
asvitkine 2007-01-24 02:37:06 +00:00
parent ab86a395da
commit f12f5173be
5 changed files with 33 additions and 1 deletions

View File

@ -438,3 +438,19 @@ const char *host_encoding_to_macroman(const char *filename)
return 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;
}

View File

@ -382,3 +382,11 @@ const char *host_encoding_to_macroman(const char *filename)
{ {
return filename; return filename;
} }
// Convert from MacRoman to host OS filename encoding
const char *macroman_to_host_encoding(const char *filename)
{
return filename;
}

View File

@ -390,3 +390,10 @@ const char *host_encoding_to_macroman(const char *filename)
{ {
return filename; return filename;
} }
// Convert from MacRoman to host OS filename encoding
const char *macroman_to_host_encoding(const char *filename)
{
return filename;
}

View File

@ -274,7 +274,7 @@ static FSItem *find_fsitem_guest(const char *guest_name, FSItem *parent)
} }
// Not found, construct new FSItem // 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);
} }
/* /*

View File

@ -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_remove(const char *path);
extern bool extfs_rename(const char *old_path, const char *new_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 *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 // Maximum length of full path name
const int MAX_PATH_LENGTH = 1024; const int MAX_PATH_LENGTH = 1024;