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.
This commit is contained in:
Sergey Sharybin
2012-10-06 07:03:03 +00:00
parent 950ac47250
commit c001bd81a7
3 changed files with 31 additions and 12 deletions

View File

@@ -96,6 +96,8 @@ void BLI_file_free_lines(struct LinkNode *lines);
# ifndef O_BINARY # ifndef O_BINARY
# define O_BINARY 0 # define O_BINARY 0
# endif # endif
#else
void BLI_get_short_name(char short_name[256], const char *filename);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -210,22 +210,11 @@ FILE *BLI_fopen(const char *filename, const char *mode)
return ufopen(filename, mode); return ufopen(filename, mode);
} }
void *BLI_gzopen(const char *filename, const char *mode) void BLI_get_short_name(char short_name[256], const char *filename)
{ {
gzFile gzfile;
if (!filename || !mode) {
return 0;
}
else {
wchar_t short_name_16[256]; wchar_t short_name_16[256];
char short_name[256];
int i = 0; int i = 0;
/* xxx Creates file before transcribing the path */
if (mode[0] == 'w')
fclose(ufopen(filename, "a"));
UTF16_ENCODE(filename); UTF16_ENCODE(filename);
GetShortPathNameW(filename_16, short_name_16, 256); GetShortPathNameW(filename_16, short_name_16, 256);
@@ -234,11 +223,28 @@ void *BLI_gzopen(const char *filename, const char *mode)
short_name[i] = (char)short_name_16[i]; short_name[i] = (char)short_name_16[i];
} }
gzfile = gzopen(short_name, mode);
UTF16_UN_ENCODE(filename); UTF16_UN_ENCODE(filename);
} }
void *BLI_gzopen(const char *filename, const char *mode)
{
gzFile gzfile;
if (!filename || !mode) {
return 0;
}
else {
char short_name[256];
/* xxx Creates file before transcribing the path */
if (mode[0] == 'w')
fclose(ufopen(filename, "a"));
BLI_get_short_name(short_name, filename);
gzfile = gzopen(short_name, mode);
}
return gzfile; return gzfile;
} }

View File

@@ -51,6 +51,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLI_blenlib.h" #include "BLI_blenlib.h"
#include "BLI_fileops.h"
#include "BLI_math.h" #include "BLI_math.h"
#include "BLI_math_color.h" #include "BLI_math_color.h"
#include "BLI_path_util.h" #include "BLI_path_util.h"
@@ -577,7 +578,17 @@ void colormanagement_init(void)
if (configdir) { if (configdir) {
BLI_join_dirfile(configfile, sizeof(configfile), configdir, BCM_CONFIG_FILE); BLI_join_dirfile(configfile, sizeof(configfile), configdir, BCM_CONFIG_FILE);
#ifdef WIN32
{
/* quite a hack to support loading configuration from path with non-acii symbols */
char short_name[256];
BLI_get_short_name(short_name, configfile);
config = OCIO_configCreateFromFile(short_name);
}
#else
config = OCIO_configCreateFromFile(configfile); config = OCIO_configCreateFromFile(configfile);
#endif
} }
} }