From c001bd81a75b60a491ae30947736eea78260827a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 6 Oct 2012 07:03:03 +0000 Subject: Color Management: fixed loading configuration from non-ascii paths Used the same hack as BLI gzip is using -- calculate short path and send it to OCIO library. --- source/blender/blenlib/intern/fileops.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'source/blender/blenlib/intern/fileops.c') diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 453463beaa8..1df904f617a 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -210,6 +210,22 @@ FILE *BLI_fopen(const char *filename, const char *mode) return ufopen(filename, mode); } +void BLI_get_short_name(char short_name[256], const char *filename) +{ + wchar_t short_name_16[256]; + int i = 0; + + UTF16_ENCODE(filename); + + GetShortPathNameW(filename_16, short_name_16, 256); + + for (i = 0; i < 256; i++) { + short_name[i] = (char)short_name_16[i]; + } + + UTF16_UN_ENCODE(filename); +} + void *BLI_gzopen(const char *filename, const char *mode) { gzFile gzfile; @@ -218,25 +234,15 @@ void *BLI_gzopen(const char *filename, const char *mode) return 0; } else { - wchar_t short_name_16[256]; char short_name[256]; - int i = 0; /* xxx Creates file before transcribing the path */ if (mode[0] == 'w') fclose(ufopen(filename, "a")); - UTF16_ENCODE(filename); - - GetShortPathNameW(filename_16, short_name_16, 256); - - for (i = 0; i < 256; i++) { - short_name[i] = (char)short_name_16[i]; - } + BLI_get_short_name(short_name, filename); gzfile = gzopen(short_name, mode); - - UTF16_UN_ENCODE(filename); } return gzfile; -- cgit v1.2.3