[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51108] trunk/blender/source/blender: Color Management: fixed loading configuration from non-ascii paths

Sergey Sharybin sergey.vfx at gmail.com
Sat Oct 6 09:03:04 CEST 2012


Revision: 51108
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51108
Author:   nazgul
Date:     2012-10-06 07:03:03 +0000 (Sat, 06 Oct 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_fileops.h
    trunk/blender/source/blender/blenlib/intern/fileops.c
    trunk/blender/source/blender/imbuf/intern/colormanagement.c

Modified: trunk/blender/source/blender/blenlib/BLI_fileops.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_fileops.h	2012-10-06 03:56:09 UTC (rev 51107)
+++ trunk/blender/source/blender/blenlib/BLI_fileops.h	2012-10-06 07:03:03 UTC (rev 51108)
@@ -96,6 +96,8 @@
 #  ifndef O_BINARY
 #    define O_BINARY 0
 #  endif
+#else
+void BLI_get_short_name(char short_name[256], const char *filename);
 #endif
 
 #ifdef __cplusplus

Modified: trunk/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/fileops.c	2012-10-06 03:56:09 UTC (rev 51107)
+++ trunk/blender/source/blender/blenlib/intern/fileops.c	2012-10-06 07:03:03 UTC (rev 51108)
@@ -210,6 +210,22 @@
 	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 @@
 		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);
+		BLI_get_short_name(short_name, filename);
 
-		GetShortPathNameW(filename_16, short_name_16, 256);
-
-		for (i = 0; i < 256; i++) {
-			short_name[i] = (char)short_name_16[i];
-		}
-
 		gzfile = gzopen(short_name, mode);
-
-		UTF16_UN_ENCODE(filename);
 	}
 
 	return gzfile;

Modified: trunk/blender/source/blender/imbuf/intern/colormanagement.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/colormanagement.c	2012-10-06 03:56:09 UTC (rev 51107)
+++ trunk/blender/source/blender/imbuf/intern/colormanagement.c	2012-10-06 07:03:03 UTC (rev 51108)
@@ -51,6 +51,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_fileops.h"
 #include "BLI_math.h"
 #include "BLI_math_color.h"
 #include "BLI_path_util.h"
@@ -574,10 +575,20 @@
 	if (config == NULL) {
 		configdir = BLI_get_folder(BLENDER_DATAFILES, "colormanagement");
 
-		if (configdir) 	{
+		if (configdir) {
 			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);
+#endif
 		}
 	}
 




More information about the Bf-blender-cvs mailing list