[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46635] trunk/blender/source/blender/ blenlib/intern/fileops.c: revert 46626, which crashes blender during startup with fileno

Sv. Lockal lockalsash at gmail.com
Mon May 14 17:50:36 CEST 2012


Revision: 46635
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46635
Author:   lockal
Date:     2012-05-14 15:50:35 +0000 (Mon, 14 May 2012)
Log Message:
-----------
revert 46626, which crashes blender during startup with fileno

There is a better way to fix this by zlib upgrade, which has its own open function for windows paths

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/fileops.c

Modified: trunk/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/fileops.c	2012-05-14 15:24:13 UTC (rev 46634)
+++ trunk/blender/source/blender/blenlib/intern/fileops.c	2012-05-14 15:50:35 UTC (rev 46635)
@@ -211,31 +211,33 @@
 
 void *BLI_gzopen(const char *filename, const char *mode)
 {
-	FILE *file;
-	gzFile gzfile = NULL;
-	wchar_t short_name_16[256];
+	gzFile gzfile;
 
-	if (!filename || !mode) 
+	if (!filename || !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"));
+		/* xxx Creates file before transcribing the path */
+		if (mode[0] == 'w')
+			fclose(ufopen(filename, "a"));
 
-	UTF16_ENCODE(filename);
-	UTF16_ENCODE(mode);
+		UTF16_ENCODE(filename);
 
-	GetShortPathNameW(filename_16, short_name_16, 256);
+		GetShortPathNameW(filename_16, short_name_16, 256);
 
-	if ((file = _wfopen(short_name_16, mode_16))) {
-		if (!(gzfile = gzdopen(fileno(file), mode))) {
-			fclose(file);
+		for (i = 0; i < 256; i++) {
+			short_name[i] = (char)short_name_16[i];
 		}
+
+		gzfile = gzopen(short_name, mode);
+
+		UTF16_UN_ENCODE(filename);
 	}
 
-	UTF16_UN_ENCODE(mode);
-	UTF16_UN_ENCODE(filename);
-
 	return gzfile;
 }
 




More information about the Bf-blender-cvs mailing list