Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/blender.c2
-rw-r--r--source/blender/blenkernel/intern/customdata_file.c4
-rw-r--r--source/blender/blenkernel/intern/image.c2
-rw-r--r--source/blender/blenkernel/intern/movieclip.c2
-rw-r--r--source/blender/blenkernel/intern/packedFile.c6
-rw-r--r--source/blender/blenkernel/intern/particle_system.c2
-rw-r--r--source/blender/blenkernel/intern/pointcache.c6
-rw-r--r--source/blender/blenkernel/intern/text.c5
-rw-r--r--source/blender/blenlib/BLI_fileops.h7
-rw-r--r--source/blender/blenlib/BLI_winstuff.h2
-rw-r--r--source/blender/blenlib/CMakeLists.txt6
-rw-r--r--source/blender/blenlib/SConscript1
-rw-r--r--source/blender/blenlib/intern/dynlib.c8
-rw-r--r--source/blender/blenlib/intern/fileops.c104
-rw-r--r--source/blender/blenlib/intern/path_util.c19
-rw-r--r--source/blender/blenlib/intern/storage.c83
-rw-r--r--source/blender/blenlib/intern/winstuff.c50
-rw-r--r--source/blender/blenloader/intern/readfile.c2
-rw-r--r--source/blender/blenloader/intern/runtime.c4
-rw-r--r--source/blender/blenloader/intern/writefile.c2
-rw-r--r--source/blender/editors/armature/reeb.c2
-rw-r--r--source/blender/editors/curve/editfont.c2
-rw-r--r--source/blender/editors/physics/physics_fluid.c2
-rw-r--r--source/blender/editors/space_file/fsmenu.c4
-rw-r--r--source/blender/editors/space_text/text_ops.c2
-rw-r--r--source/blender/imbuf/CMakeLists.txt6
-rw-r--r--source/blender/imbuf/SConscript1
-rw-r--r--source/blender/imbuf/intern/bmp.c2
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c5
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c7
-rw-r--r--source/blender/imbuf/intern/cineon/logImageLib.c3
-rw-r--r--source/blender/imbuf/intern/indexer.c8
-rw-r--r--source/blender/imbuf/intern/iris.c2
-rw-r--r--source/blender/imbuf/intern/jp2.c2
-rw-r--r--source/blender/imbuf/intern/jpeg.c6
-rw-r--r--source/blender/imbuf/intern/png.c2
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c2
-rw-r--r--source/blender/imbuf/intern/readimage.c6
-rw-r--r--source/blender/imbuf/intern/targa.c2
-rw-r--r--source/blender/imbuf/intern/thumbs.c7
-rw-r--r--source/blender/imbuf/intern/thumbs_blend.c4
-rw-r--r--source/blender/imbuf/intern/util.c2
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c6
-rw-r--r--source/blender/python/intern/bpy_interface.c3
-rw-r--r--source/blender/render/intern/source/voxeldata.c4
-rw-r--r--source/blender/windowmanager/CMakeLists.txt6
-rw-r--r--source/blender/windowmanager/SConscript1
-rw-r--r--source/blender/windowmanager/intern/wm_files.c6
48 files changed, 300 insertions, 122 deletions
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 30f4e9f2816..2ef93dd7fa3 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -717,7 +717,7 @@ void BKE_undo_save_quit(void)
BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
- file = open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
+ file = BLI_open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
if(file == -1) {
//XXX error("Unable to save %s, check you have permissions", str);
return;
diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c
index 4386132fc18..5538267a5f1 100644
--- a/source/blender/blenkernel/intern/customdata_file.c
+++ b/source/blender/blenkernel/intern/customdata_file.c
@@ -279,7 +279,7 @@ int cdf_read_open(CDataFile *cdf, const char *filename)
{
FILE *f;
- f= fopen(filename, "rb");
+ f= BLI_fopen(filename, "rb");
if(!f)
return 0;
@@ -350,7 +350,7 @@ int cdf_write_open(CDataFile *cdf, const char *filename)
CDataFileMeshHeader *mesh;
FILE *f;
- f= fopen(filename, "wb");
+ f= BLI_fopen(filename, "wb");
if(!f)
return 0;
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 4300995b68c..053ebf654f0 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -521,7 +521,7 @@ Image *BKE_add_image_file(const char *name)
BLI_path_abs(str, G.main->name);
/* exists? */
- file= open(str, O_BINARY|O_RDONLY);
+ file= BLI_open(str, O_BINARY|O_RDONLY, 0);
if(file== -1) return NULL;
close(file);
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 0af6b9dd219..1b415f1654f 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -411,7 +411,7 @@ MovieClip *BKE_add_movieclip_file(const char *name)
BLI_path_abs(str, G.main->name);
/* exists? */
- file= open(str, O_BINARY|O_RDONLY);
+ file= BLI_open(str, O_BINARY|O_RDONLY,0);
if(file== -1) return NULL;
close(file);
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 4230510dac9..64ccdf9b843 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -186,7 +186,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
// open the file
// and create a PackedFile structure
- file= open(name, O_BINARY|O_RDONLY);
+ file= BLI_open(name, O_BINARY|O_RDONLY,0);
if (file <= 0) {
BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name);
} else {
@@ -292,7 +292,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
// make sure the path to the file exists...
BLI_make_existing_file(name);
- file = open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
+ file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
if (file >= 0) {
if (write(file, pf->data, pf->size) != pf->size) {
BKE_reportf(reports, RPT_ERROR, "Error writing file: %s", name);
@@ -347,7 +347,7 @@ int checkPackedFile(const char *filename, PackedFile *pf)
} else {
// we'll have to compare the two...
- file = open(name, O_BINARY | O_RDONLY);
+ file = BLI_open(name, O_BINARY | O_RDONLY, 0);
if (file < 0) {
ret_val = PF_NOFILE;
} else {
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index a0668d621e8..978971a04a4 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4073,7 +4073,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
BLI_path_frame(filename, curFrame, 0); // fixed #frame-no
- gzf = gzopen(filename, "rb");
+ gzf = BLI_gzopen(filename, "rb");
if (!gzf) {
BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer),"readFsPartData::error - Unable to open file for reading '%s' \n", filename);
// XXX bad level call elbeemDebugOut(debugStrBuffer);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 69e96c7a698..a2425b0a3ac 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1144,13 +1144,13 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
if (!BLI_exists(filename)) {
return NULL;
}
- fp = fopen(filename, "rb");
+ fp = BLI_fopen(filename, "rb");
} else if (mode==PTCACHE_FILE_WRITE) {
BLI_make_existing_file(filename); /* will create the dir if needs be, same as //textures is created */
- fp = fopen(filename, "wb");
+ fp = BLI_fopen(filename, "wb");
} else if (mode==PTCACHE_FILE_UPDATE) {
BLI_make_existing_file(filename);
- fp = fopen(filename, "rb+");
+ fp = BLI_fopen(filename, "rb+");
}
if (!fp)
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index ffb8e830ed4..66759edde65 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -44,6 +44,7 @@
#include "BLI_string_utf8.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
+#include "BLI_fileops.h"
#include "DNA_constraint_types.h"
#include "DNA_controller_types.h"
@@ -291,7 +292,7 @@ int reopen_text(Text *text)
BLI_strncpy(str, text->name, FILE_MAX);
BLI_path_abs(str, G.main->name);
- fp= fopen(str, "r");
+ fp= BLI_fopen(str, "r");
if(fp==NULL) return 0;
/* free memory: */
@@ -387,7 +388,7 @@ Text *add_text(const char *file, const char *relpath)
if (relpath) /* can be NULL (bg mode) */
BLI_path_abs(str, relpath);
- fp= fopen(str, "r");
+ fp= BLI_fopen(str, "r");
if(fp==NULL) return NULL;
ta= alloc_libblock(&bmain->text, ID_TXT, BLI_path_basename(str));
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index 8fe8456e845..fa1a61998d7 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -33,6 +33,9 @@
#ifndef __BLI_FILEOPS_H__
#define __BLI_FILEOPS_H__
+#include <stdio.h>
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -65,6 +68,10 @@ unsigned int BLI_dir_contents(const char *dir, struct direntry **filelist);
/* Files */
+FILE * BLI_fopen(const char * filename, const char * mode);
+void* BLI_gzopen(const char * filename, const char * mode);
+int BLI_open(const char *filename, int oflag, int pmode);
+
int BLI_file_is_writable(const char *file);
int BLI_file_touch(const char *file);
diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h
index d939882b105..c393b219785 100644
--- a/source/blender/blenlib/BLI_winstuff.h
+++ b/source/blender/blenlib/BLI_winstuff.h
@@ -124,7 +124,7 @@ struct dirent {
typedef struct _DIR {
HANDLE handle;
- WIN32_FIND_DATA data;
+ WIN32_FIND_DATAW data;
char path[MAX_PATH];
long dd_loc;
long dd_size;
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index ddcc344e939..c06a1240729 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -160,4 +160,10 @@ if(WITH_XDG_USER_DIRS)
add_definitions(-DWITH_XDG_USER_DIRS)
endif()
+if(WIN32)
+ list(APPEND INC
+ ../../../intern/utfconv
+ )
+endif()
+
blender_add_lib(bf_blenlib "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/blenlib/SConscript b/source/blender/blenlib/SConscript
index dda8303eea7..ea51e5b6ab5 100644
--- a/source/blender/blenlib/SConscript
+++ b/source/blender/blenlib/SConscript
@@ -18,6 +18,7 @@ if env['WITH_BF_BINRELOC']:
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
incs += ' ' + env['BF_PTHREADS_INC']
+ incs += ' ../../../intern/utfconv'
if env['OURPLATFORM'] == 'linuxcross':
if env['WITH_BF_OPENMP']:
diff --git a/source/blender/blenlib/intern/dynlib.c b/source/blender/blenlib/intern/dynlib.c
index 0bfa5e79eb8..c23feb975df 100644
--- a/source/blender/blenlib/intern/dynlib.c
+++ b/source/blender/blenlib/intern/dynlib.c
@@ -44,11 +44,17 @@ struct DynamicLibrary {
#ifdef WIN32
#include <windows.h>
+#include "utf_winfunc.h"
+#include "utfconv.h"
DynamicLibrary *BLI_dynlib_open(char *name)
{
DynamicLibrary *lib;
- void *handle= LoadLibrary(name);
+ void *handle;
+
+ UTF16_ENCODE(name);
+ handle= LoadLibraryW(name_16);
+ UTF16_UN_ENCODE(name);
if(!handle)
return NULL;
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index ab7beeeb8f1..9527ec9466b 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -45,6 +45,8 @@
#include <io.h>
#include "BLI_winstuff.h"
#include "BLI_callbacks.h"
+#include "utf_winfunc.h"
+#include "utfconv.h"
#else
#include <unistd.h> // for read close
#include <sys/param.h>
@@ -77,11 +79,10 @@ int BLI_file_gzip(const char *from, const char *to)
/* level 1 is very close to 3 (the default) in terms of file size,
* but about twice as fast, best use for speedy saving - campbell */
- gzfile = gzopen(to, "wb1");
+ gzfile = BLI_gzopen(to, "wb1");
if(gzfile == NULL)
return -1;
-
- file = open(from, O_BINARY|O_RDONLY);
+ file = BLI_open(from, O_BINARY|O_RDONLY,0);
if(file < 0)
return -2;
@@ -121,8 +122,7 @@ char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r)
size= 0;
- gzfile = gzopen( from_file, "rb" );
-
+ gzfile = BLI_gzopen( from_file, "rb" );
for(;;) {
if(mem==NULL) {
mem= MEM_callocN(chunk_size, "BLI_ungzip_to_mem");
@@ -158,12 +158,12 @@ int BLI_file_is_writable(const char *filename)
int file;
/* first try to open without creating */
- file = open(filename, O_BINARY | O_RDWR, 0666);
+ file = BLI_open(filename, O_BINARY | O_RDWR, 0666);
if (file < 0) {
/* now try to open and create. a test without actually
* creating a file would be nice, but how? */
- file = open(filename, O_BINARY | O_RDWR | O_CREAT, 0666);
+ file = BLI_open(filename, O_BINARY | O_RDWR | O_CREAT, 0666);
if(file < 0) {
return 0;
@@ -183,13 +183,13 @@ int BLI_file_is_writable(const char *filename)
int BLI_file_touch(const char *file)
{
- FILE *f = fopen(file,"r+b");
+ FILE *f = BLI_fopen(file,"r+b");
if (f != NULL) {
char c = getc(f);
rewind(f);
putc(c,f);
} else {
- f = fopen(file,"wb");
+ f = BLI_fopen(file,"wb");
}
if (f) {
fclose(f);
@@ -202,21 +202,63 @@ int BLI_file_touch(const char *file)
static char str[MAXPATHLEN+12];
+FILE * BLI_fopen(const char * filename, const char * mode)
+{
+ return ufopen(filename, mode);
+}
+
+gzFile BLI_gzopen(const char * filename, const char * mode)
+{
+ gzFile gzfile;
+ int fi;
+
+ if(!filename || !mode) {return 0;}
+ else
+
+ {
+
+ wchar_t short_name_16 [256];
+ char short_name [256];
+ int i=0;
+ UTF16_ENCODE(filename);
+
+ GetShortPathNameW(filename_16,short_name_16,256);
+
+ for(i=0;i<256;i++) {short_name[i]=short_name_16[i];};
+
+
+ gzfile = gzopen(short_name,mode);
+
+ UTF16_UN_ENCODE(filename);
+
+ }
+ return gzfile;
+}
+
+int BLI_open(const char *filename, int oflag, int pmode)
+{
+ return uopen(filename, oflag, pmode);
+}
+
int BLI_delete(const char *file, int dir, int recursive)
{
int err;
+
+ UTF16_ENCODE(file)
if (recursive) {
callLocalErrorCallBack("Recursive delete is unsupported on Windows");
err= 1;
} else if (dir) {
- err= !RemoveDirectory(file);
+ err= !RemoveDirectoryW(file_16);
if (err) printf ("Unable to remove directory");
} else {
- err= !DeleteFile(file);
+ err= !DeleteFileW(file_16);
if (err) callLocalErrorCallBack("Unable to delete file");
}
+ UTF16_UN_ENCODE(file)
+
return err;
}
@@ -235,8 +277,13 @@ int BLI_move(const char *file, const char *to)
strcat(str, BLI_last_slash(file) + 1);
}
}
+
+ UTF16_ENCODE(file)
+ UTF16_ENCODE(str)
+ err= !MoveFileW(file_16, str_16);
+ UTF16_UN_ENCODE(str)
+ UTF16_UN_ENCODE(file)
- err= !MoveFile(file, str);
if (err) {
callLocalErrorCallBack("Unable to move file");
printf(" Move from '%s' to '%s' failed\n", file, str);
@@ -262,8 +309,12 @@ int BLI_copy(const char *file, const char *to)
}
}
- err= !CopyFile(file,str,FALSE);
-
+ UTF16_ENCODE(file)
+ UTF16_ENCODE(str)
+ err= !CopyFileW(file_16,str_16,FALSE);
+ UTF16_UN_ENCODE(str)
+ UTF16_UN_ENCODE(file)
+
if (err) {
callLocalErrorCallBack("Unable to copy file!");
printf(" Copy from '%s' to '%s' failed\n", file, str);
@@ -292,7 +343,7 @@ void BLI_dir_create_recursive(const char *dirname)
BLI_strncpy(tmp, dirname, sizeof(tmp));
lslash= BLI_last_slash(tmp);
-
+
if (lslash == tmp + strlen(tmp) - 1) {
*lslash = 0;
}
@@ -307,8 +358,8 @@ void BLI_dir_create_recursive(const char *dirname)
}
if(dirname[0]) /* patch, this recursive loop tries to create a nameless directory */
- if (!CreateDirectory(dirname, NULL))
- callLocalErrorCallBack("Unable to create directory\n");
+ if (umkdir(dirname)==-1)
+ printf("Unable to create directory %s\n",dirname);
}
int BLI_rename(const char *from, const char *to)
@@ -318,8 +369,8 @@ int BLI_rename(const char *from, const char *to)
/* make sure the filenames are different (case insensitive) before removing */
if (BLI_exists(to) && BLI_strcasecmp(from, to))
if(BLI_delete(to, 0, 0)) return 1;
-
- return rename(from, to);
+
+ return urename(from, to);
}
#else /* The UNIX world */
@@ -499,6 +550,21 @@ static int delete_single_file(const char *from, const char *UNUSED(to))
return recursiveOp_Callback_OK;
}
+FILE * BLI_fopen(const char * filename, const char * mode)
+{
+ return fopen(filename, mode);
+}
+
+gzFile BLI_gzopen(const char * filename, const char * mode)
+{
+ return gzopen(filename, mode);
+}
+
+int BLI_open(const char *filename, int oflag, int pmode)
+{
+ return open(filename, oflag, pmode);
+}
+
int BLI_delete(const char *file, int dir, int recursive)
{
if(strchr(file, '"')) {
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 9c80fa9ca15..ccf85934788 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -62,6 +62,7 @@
#endif
#ifdef WIN32
+#include "utf_winfunc.h"
# include <io.h>
# ifdef _WIN32_IE
# undef _WIN32_IE
@@ -825,10 +826,8 @@ const char *BLI_getDefaultDocumentFolder(void)
HRESULT hResult;
/* Check for %HOME% env var */
-
- ret = getenv("HOME");
- if(ret) {
- if (BLI_is_dir(ret)) return ret;
+ if(uput_getenv("HOME",documentfolder,MAXPATHLEN)) {
+ if (BLI_is_dir(documentfolder)) return documentfolder;
}
/* add user profile support for WIN 2K / NT.
@@ -1186,7 +1185,9 @@ void BLI_setenv(const char *env, const char*val)
/* non-free windows */
#elif (defined(WIN32) || defined(WIN64)) /* not free windows */
- _putenv_s(env, val);
+ uputenv(env, val);
+
+
#else
/* linux/osx/bsd */
setenv(env, val, 1);
@@ -1774,17 +1775,23 @@ static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name
#endif
#ifdef _WIN32
- if(GetModuleFileName(0, fullname, maxlen)) {
+ wchar_t * fullname_16 = MEM_mallocN(maxlen*sizeof(wchar_t), "ProgramPath");
+ if(GetModuleFileNameW(0, fullname_16, maxlen)) {
+ conv_utf_16_to_8(fullname_16,fullname, maxlen);
if(!BLI_exists(fullname)) {
printf("path can't be found: \"%.*s\"\n", maxlen, fullname);
MessageBox(NULL, "path contains invalid characters or is too long (see console)", "Error", MB_OK);
}
+ MEM_freeN(fullname_16);
return;
}
+
+ MEM_freeN(fullname_16);
#endif
/* unix and non linux */
if (name && name[0]) {
+
BLI_strncpy(fullname, name, maxlen);
if (name[0] == '.') {
char wdir[FILE_MAX]= "";
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 29f11ee0550..363052c7255 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -78,6 +78,7 @@
#include <io.h>
#include <direct.h>
#include "BLI_winstuff.h"
+#include "utfconv.h"
#endif
@@ -86,10 +87,13 @@
#include "DNA_listBase.h"
-#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_linklist.h"
+#include "BLI_fileops.h"
+
+#include "BLI_fileops_types.h"
#include "BLI_string.h"
+#include "BLI_fileops.h"
#include "BKE_utildefines.h"
@@ -210,13 +214,22 @@ static void bli_builddir(const char *dirname, const char *relname)
buf[rellen]='/';
rellen++;
}
-
+#ifndef WIN32
if (chdir(dirname) == -1) {
perror(dirname);
return;
}
+#else
+ UTF16_ENCODE(dirname)
+ if(!SetCurrentDirectoryW(dirname_16)){
+ perror(dirname);
+ free(dirname_16);
+ return;
+ }
+ UTF16_UN_ENCODE(dirname)
- if ( (dir = (DIR *)opendir(".")) ) {
+#endif
+ if ( (dir = (DIR *)opendir(".")) ){
while ((fname = (struct dirent*) readdir(dir)) != NULL) {
dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
if (dlink) {
@@ -250,11 +263,16 @@ static void bli_builddir(const char *dirname, const char *relname)
files[actnum].relname = dlink->name;
files[actnum].path = BLI_strdupcat(dirname, dlink->name);
// use 64 bit file size, only needed for WIN32 and WIN64.
-// Excluding other than current MSVC compiler until able to test.
+// Excluding other than current MSVC compiler until able to test
+#ifdef WIN32
+ {wchar_t * name_16 = alloc_utf16_from_8(dlink->name,0);
#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500)
- _stat64(dlink->name,&files[actnum].s);
+ _wstat64(name_16,&files[actnum].s);
#elif defined(__MINGW32__)
_stati64(dlink->name,&files[actnum].s);
+#endif
+ free(name_16);};
+
#else
stat(dlink->name,&files[actnum].s);
#endif
@@ -423,13 +441,13 @@ size_t BLI_file_descriptor_size(int file)
struct stat buf;
if (file <= 0) return (-1);
- fstat(file, &buf);
+ fstat(file, &buf);//CHANGE
return (buf.st_size);
}
size_t BLI_file_size(const char *path)
{
- int size, file = open(path, O_BINARY|O_RDONLY);
+ int size, file = BLI_open(path, O_BINARY|O_RDONLY, 0);
if (file == -1)
return -1;
@@ -442,27 +460,26 @@ size_t BLI_file_size(const char *path)
int BLI_exists(const char *name)
{
-#if defined(WIN32) && !defined(__MINGW32__)
+#if defined(WIN32)
+#ifndef __MINGW32__
struct _stat64i32 st;
- /* in Windows stat doesn't recognize dir ending on a slash
- * To not break code where the ending slash is expected we
- * don't mess with the argument name directly here - elubie */
- char tmp[FILE_MAX];
- int len, res;
- BLI_strncpy(tmp, name, FILE_MAX);
- len = strlen(tmp);
- if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0';
- res = _stat(tmp, &st);
- if (res == -1) return(0);
-#elif defined(__MINGW32__)
+#else
struct _stati64 st;
- char tmp[FILE_MAX];
+#endif
+ /* in Windows stat doesn't recognize dir ending on a slash
+ To not break code where the ending slash is expected we
+ don't mess with the argument name directly here - elubie */
+ wchar_t * tmp_16 = alloc_utf16_from_8(name, 0);
int len, res;
- BLI_strncpy(tmp, name, FILE_MAX);
- len = strlen(tmp);
- if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0';
- res = _stati64(tmp, &st);
- if (res) return(0);
+ len = wcslen(tmp_16);
+ if (len > 3 && ( tmp_16[len-1]==L'\\' || tmp_16[len-1]==L'/') ) tmp_16[len-1] = '\0';
+#ifndef __MINGW32__
+ res = _wstat(tmp_16, &st);
+#else
+ res = _wstati64(tmp_16, &st);
+#endif
+ free(tmp_16);
+ if (res == -1) return(0);
#else
struct stat st;
if (stat(name,&st)) return(0);
@@ -484,7 +501,7 @@ int BLI_is_file(const char *path)
LinkNode *BLI_file_read_as_lines(const char *name)
{
- FILE *fp= fopen(name, "r");
+ FILE *fp= BLI_fopen(name, "r");
LinkNode *lines= NULL;
char *buf;
size_t size;
@@ -530,11 +547,23 @@ void BLI_file_free_lines(LinkNode *lines)
int BLI_file_older(const char *file1, const char *file2)
{
+#if WIN32
+ struct _stat st1, st2;
+
+ UTF16_ENCODE(file1)
+ UTF16_ENCODE(file2)
+
+ if(_wstat(file1_16, &st1)) return 0;
+ if(_wstat(file2_16, &st2)) return 0;
+
+ UTF16_UN_ENCODE(file2)
+ UTF16_UN_ENCODE(file1)
+#else
struct stat st1, st2;
if(stat(file1, &st1)) return 0;
if(stat(file2, &st2)) return 0;
-
+#endif
return (st1.st_mtime < st2.st_mtime);
}
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index 4665b08b202..7fc2e52255c 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -47,13 +47,16 @@
#define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY
#include "BLI_winstuff.h"
- /* FILE_MAX */
+#include "utf_winfunc.h"
+#include "utfconv.h"
+
+ /* FILE_MAXDIR + FILE_MAXFILE */
int BLI_getInstallationDir( char * str )
{
char dir[FILE_MAXDIR];
int a;
-
+ /*change to utf support*/
GetModuleFileName(NULL,str,FILE_MAX);
BLI_split_dir_part(str, dir, sizeof(dir)); /* shouldn't be relative */
a = strlen(dir);
@@ -169,7 +172,9 @@ void RegisterBlendExtension(void)
DIR *opendir (const char *path)
{
- if (GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY) {
+ wchar_t * path_16 = alloc_utf16_from_8(path, 0);
+
+ if (GetFileAttributesW(path_16) & FILE_ATTRIBUTE_DIRECTORY) {
DIR *newd= MEM_mallocN(sizeof(DIR), "opendir");
newd->handle = INVALID_HANDLE_VALUE;
@@ -180,29 +185,56 @@ DIR *opendir (const char *path)
newd->direntry.d_reclen= 0;
newd->direntry.d_name= NULL;
+ free(path_16);
return newd;
} else {
+ free(path_16);
return NULL;
}
}
-struct dirent *readdir(DIR *dp)
+static char * BLI_alloc_utf_8_from_16(wchar_t * in16, size_t add)
+{
+ size_t bsize = count_utf_8_from_16(in16);
+ char * out8 = NULL;
+ if(!bsize) return NULL;
+ out8 = (char*)MEM_mallocN(sizeof(char) * (bsize + add),"UTF-8 String");
+ conv_utf_16_to_8(in16,out8, bsize);
+ return out8;
+}
+
+static wchar_t * BLI_alloc_utf16_from_8(char * in8, size_t add)
{
+ size_t bsize = count_utf_16_from_8(in8);
+ wchar_t * out16 = NULL;
+ if(!bsize) return NULL;
+ out16 =(wchar_t*) MEM_mallocN(sizeof(wchar_t) * (bsize + add), "UTF-16 String");
+ conv_utf_8_to_16(in8,out16, bsize);
+ return out16;
+}
+
+
+
+struct dirent *readdir(DIR *dp) {
+ char * FileName;
+ size_t size;
if (dp->direntry.d_name) {
MEM_freeN(dp->direntry.d_name);
dp->direntry.d_name= NULL;
}
if (dp->handle==INVALID_HANDLE_VALUE) {
- dp->handle= FindFirstFile(dp->path, &(dp->data));
+ wchar_t * path_16 = alloc_utf16_from_8(dp->path, 0);
+ dp->handle= FindFirstFileW(path_16, &(dp->data));
+ free(path_16);
if (dp->handle==INVALID_HANDLE_VALUE)
return NULL;
- dp->direntry.d_name= BLI_strdup(dp->data.cFileName);
-
+ dp->direntry.d_name= BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
+
return &dp->direntry;
- } else if (FindNextFile (dp->handle, &(dp->data))) {
- dp->direntry.d_name= BLI_strdup(dp->data.cFileName);
+ } else if (FindNextFileW (dp->handle, &(dp->data))) {
+ dp->direntry.d_name= BLI_alloc_utf_8_from_16(dp->data.cFileName,0);
return &dp->direntry;
} else {
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 95a76dac616..7a6e23cd5bb 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -990,7 +990,7 @@ FileData *blo_openblenderfile(const char *filepath, ReportList *reports)
{
gzFile gzfile;
errno= 0;
- gzfile= gzopen(filepath, "rb");
+ gzfile= BLI_gzopen(filepath, "rb");
if (gzfile == (gzFile)Z_NULL) {
BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error reading file");
diff --git a/source/blender/blenloader/intern/runtime.c b/source/blender/blenloader/intern/runtime.c
index 3f8a9807f18..88f602641ff 100644
--- a/source/blender/blenloader/intern/runtime.c
+++ b/source/blender/blenloader/intern/runtime.c
@@ -68,7 +68,7 @@ static int handle_read_msb_int(int handle)
int BLO_is_a_runtime(const char *path)
{
- int res= 0, fd= open(path, O_BINARY|O_RDONLY, 0);
+ int res= 0, fd= BLI_open(path, O_BINARY|O_RDONLY, 0);
int datastart;
char buf[8];
@@ -102,7 +102,7 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports)
int fd, datastart;
char buf[8];
- fd= open(path, O_BINARY|O_RDONLY, 0);
+ fd= BLI_open(path, O_BINARY|O_RDONLY, 0);
if(fd==-1) {
BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", path, strerror(errno));
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 8cd6712c560..02de7a371ff 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2887,7 +2887,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
/* open temporary file, so we preserve the original in case we crash */
BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
- file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
+ file = BLI_open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
if(file == -1) {
BKE_reportf(reports, RPT_ERROR, "Can't open file %s for writing: %s.", tempname, strerror(errno));
return 0;
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index bb24a1d8412..e832247e67c 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -2051,7 +2051,7 @@ void REEB_exportGraph(ReebGraph *rg, int count)
else {
sprintf(filename, "test%05i.txt", count);
}
- f = fopen(filename, "w");
+ f = BLI_fopen(filename, "w");
for(arc = rg->arcs.first; arc; arc = arc->next)
{
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index efde93b4ad7..4170b7e3299 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -348,7 +348,7 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename)
int filelen;
char *strp;
- fp= fopen(filename, "r");
+ fp= BLI_fopen(filename, "r");
if(!fp) {
if(reports)
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index dbdee3baca8..43b1a4517ad 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -684,7 +684,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF
// check selected directory
// simply try to open cfg file for writing to test validity of settings
- fileCfg = fopen(targetFile, "w");
+ fileCfg = BLI_fopen(targetFile, "w");
if(fileCfg) {
dirExist = 1; fclose(fileCfg);
// remove cfg dummy from directory test
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 4c9d2be791b..8b98b942f42 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -233,7 +233,7 @@ void fsmenu_write_file(struct FSMenu* fsmenu, const char *filename)
FSMenuEntry *fsme= NULL;
int nskip= 0;
- FILE *fp = fopen(filename, "w");
+ FILE *fp = BLI_fopen(filename, "w");
if (!fp) return;
fprintf(fp, "[Bookmarks]\n");
@@ -262,7 +262,7 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename)
FSMenuCategory category = FS_CATEGORY_BOOKMARKS;
FILE *fp;
- fp = fopen(filename, "r");
+ fp = BLI_fopen(filename, "r");
if (!fp) return;
while ( fgets ( line, 256, fp ) != NULL ) /* read a line */
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 2f6e5082fdc..4c6357f7505 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -460,7 +460,7 @@ static void txt_write_file(Text *text, ReportList *reports)
BLI_strncpy(filepath, text->name, FILE_MAX);
BLI_path_abs(filepath, G.main->name);
- fp= fopen(filepath, "w");
+ fp= BLI_fopen(filepath, "w");
if(fp==NULL) {
BKE_reportf(reports, RPT_ERROR, "Unable to save \"%s\": %s", filepath, errno ? strerror(errno) : "Unknown error writing file");
return;
diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt
index 649b7cb1c11..aa4454562b4 100644
--- a/source/blender/imbuf/CMakeLists.txt
+++ b/source/blender/imbuf/CMakeLists.txt
@@ -180,4 +180,10 @@ if(WITH_IMAGE_HDR)
add_definitions(-DWITH_HDR)
endif()
+if(WIN32)
+ list(APPEND INC
+ ../../../intern/utfconv
+ )
+endif()
+
blender_add_lib(bf_imbuf "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript
index ca56003845f..b2b526ca17d 100644
--- a/source/blender/imbuf/SConscript
+++ b/source/blender/imbuf/SConscript
@@ -17,6 +17,7 @@ defs = []
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
incs += ' ' + env['BF_PTHREADS_INC']
+ incs += ' ../../../intern/utfconv'
if env['WITH_BF_OPENEXR']:
defs.append('WITH_OPENEXR')
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index 1b6184c8b58..1e13f5d913b 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -216,7 +216,7 @@ int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags)
bytesize = (ibuf->x * 3 + extrabytes) * ibuf->y;
data = (uchar *) ibuf->rect;
- ofile = fopen(name,"wb");
+ ofile = BLI_fopen(name,"wb");
if (!ofile) return 0;
putShortLSB(19778,ofile); /* "BM" */
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index 810ed7b26a4..a10d8c67051 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -38,6 +38,7 @@
#include <string.h> /* memset */
#include "BLI_utildefines.h"
+#include "BLI_fileops.h"
#include "cin_debug_stuff.h"
#include "logmemfile.h"
@@ -523,7 +524,7 @@ cineonOpen(const char* filename) {
cineon->memcursor = 0;
cineon->membuffersize = 0;
- cineon->file = fopen(filename, "rb");
+ cineon->file = BLI_fopen(filename, "rb");
if (cineon->file == 0) {
if (verbose) d_printf("Failed to open file \"%s\".\n", filename);
cineonClose(cineon);
@@ -727,7 +728,7 @@ cineonCreate(const char* filename, int width, int height, int depth) {
cineon->lineBuffer = 0;
cineon->pixelBuffer = 0;
- cineon->file = fopen(filename, "wb");
+ cineon->file = BLI_fopen(filename, "wb");
if (cineon->file == 0) {
if (verbose) d_printf("Couldn't open file %s\n", filename);
cineonClose(cineon);
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index a63a2ea1dab..01177b01178 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -38,6 +38,7 @@
#include <string.h> /* memset */
#include "cin_debug_stuff.h"
#include "logmemfile.h"
+#include "BLI_fileops.h"
static void
fillDpxChannelInfo(DpxFile* dpx, DpxChannelInformation* chan, int des) {
@@ -401,7 +402,7 @@ intern_dpxOpen(int mode, const char* bytestuff, int bufsize) {
if (mode == LFREALFILE) {
filename = bytestuff;
- dpx->file = fopen(filename, "rb");
+ dpx->file = BLI_fopen(filename, "rb");
if (dpx->file == 0) {
if (verbose) d_printf("Failed to open file \"%s\".\n", filename);
dpxClose(dpx);
@@ -589,7 +590,7 @@ dpxCreate(const char* filename, int width, int height, int depth) {
dpx->lineBuffer = 0;
dpx->pixelBuffer = 0;
- dpx->file = fopen(filename, "wb");
+ dpx->file = BLI_fopen(filename, "wb");
if (dpx->file == 0) {
if (verbose) d_printf("Couldn't open file %s\n", filename);
dpxClose(dpx);
@@ -687,7 +688,7 @@ dpxDump(const char* filename) {
DpxMainHeader header;
FILE* file;
- file = fopen(filename, "rb");
+ file = BLI_fopen(filename, "rb");
if (file == 0) {
d_printf("Failed to open file \"%s\".\n", filename);
return;
diff --git a/source/blender/imbuf/intern/cineon/logImageLib.c b/source/blender/imbuf/intern/cineon/logImageLib.c
index 123d0b42979..dc50d93bf18 100644
--- a/source/blender/imbuf/intern/cineon/logImageLib.c
+++ b/source/blender/imbuf/intern/cineon/logImageLib.c
@@ -36,6 +36,7 @@
#include <netinet/in.h> /* htonl() */
#endif
#include <string.h> /* memset */
+#include "BLI_fileops.h"
#define MIN_GAMMA 0.01
#define MAX_GAMMA 99.9
@@ -154,7 +155,7 @@ logImageDump(const char* filename)
U32 magic;
- FILE* foo = fopen(filename, "rb");
+ FILE* foo = BLI_fopen(filename, "rb");
if (foo == 0) {
return;
}
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index cf354371ddc..dcbce6d028c 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -81,7 +81,7 @@ anim_index_builder * IMB_index_builder_create(const char * name)
BLI_make_existing_file(rv->temp_name);
- rv->fp = fopen(rv->temp_name, "wb");
+ rv->fp = BLI_fopen(rv->temp_name, "wb");
if (!rv->fp) {
fprintf(stderr, "Couldn't open index target: %s! "
@@ -140,7 +140,7 @@ void IMB_index_builder_finish(anim_index_builder * fp, int rollback)
unlink(fp->temp_name);
} else {
unlink(fp->name);
- rename(fp->temp_name, fp->name);
+ BLI_rename(fp->temp_name, fp->name);
}
MEM_freeN(fp);
@@ -150,7 +150,7 @@ struct anim_index * IMB_indexer_open(const char * name)
{
char header[13];
struct anim_index * idx;
- FILE * fp = fopen(name, "rb");
+ FILE * fp = BLI_fopen(name, "rb");
int i;
if (!fp) {
@@ -690,7 +690,7 @@ static void free_proxy_output_ffmpeg(struct proxy_output_ctx * ctx,
get_proxy_filename(ctx->anim, ctx->proxy_size,
fname, FALSE);
unlink(fname);
- rename(fname_tmp, fname);
+ BLI_rename(fname_tmp, fname);
}
MEM_freeN(ctx);
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index 83351b5e0e4..38fc6f92c83 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -674,7 +674,7 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons
int rlebuflen, goodwrite;
goodwrite = 1;
- outf = fopen(name, "wb");
+ outf = BLI_fopen(name, "wb");
if(!outf) return 0;
tablen = ysize*zsize*sizeof(int);
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index c2bdb44be10..87450170c66 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -731,7 +731,7 @@ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags)
codestream_length = cio_tell(cio);
/* write the buffer to disk */
- f = fopen(name, "wb");
+ f = BLI_fopen(name, "wb");
if (!f) {
fprintf(stderr, "failed to open %s for writing\n", name);
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 2aab497649a..75a5f274413 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -608,7 +608,7 @@ static int save_stdjpeg(const char *name, struct ImBuf *ibuf)
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
struct my_error_mgr jerr;
- if ((outfile = fopen(name, "wb")) == NULL) return 0;
+ if ((outfile = BLI_fopen(name, "wb")) == NULL) return 0;
jpeg_default_quality = 75;
cinfo->err = jpeg_std_error(&jerr.pub);
@@ -642,7 +642,7 @@ static int save_vidjpeg(const char *name, struct ImBuf *ibuf)
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
struct my_error_mgr jerr;
- if ((outfile = fopen(name, "wb")) == NULL) return 0;
+ if ((outfile = BLI_fopen(name, "wb")) == NULL) return 0;
jpeg_default_quality = 90;
cinfo->err = jpeg_std_error(&jerr.pub);
@@ -712,7 +712,7 @@ static int save_maxjpeg(const char *name, struct ImBuf *ibuf)
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
struct my_error_mgr jerr;
- if ((outfile = fopen(name, "wb")) == NULL) return 0;
+ if ((outfile = BLI_fopen(name, "wb")) == NULL) return 0;
jpeg_default_quality = 100;
cinfo->err = jpeg_std_error(&jerr.pub);
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 84f3e18591d..78c7c672e22 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -195,7 +195,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
Flush);
}
else {
- fp = fopen(name, "wb");
+ fp = BLI_fopen(name, "wb");
if (!fp) {
png_destroy_write_struct(&png_ptr, &info_ptr);
MEM_freeN(pixels);
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index 9265da8d8dc..42e4db54f3f 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -332,7 +332,7 @@ static void writeHeader(FILE *file, int width, int height)
int imb_savehdr(struct ImBuf *ibuf, const char *name, int flags)
{
- FILE* file = fopen(name, "wb");
+ FILE* file = BLI_fopen(name, "wb");
float *fp= NULL;
int y, width=ibuf->x, height=ibuf->y;
unsigned char *cp= NULL;
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index c2f73efa63f..2ee389a42f6 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -126,7 +126,7 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags)
imb_cache_filename(filepath_tx, filepath, flags);
- file = open(filepath_tx, O_BINARY|O_RDONLY);
+ file = BLI_open(filepath_tx, O_BINARY|O_RDONLY, 0);
if(file < 0) return NULL;
ibuf= IMB_loadifffile(file, flags, filepath_tx);
@@ -152,7 +152,7 @@ ImBuf *IMB_testiffname(const char *filepath, int flags)
imb_cache_filename(filepath_tx, filepath, flags);
- file = open(filepath_tx,O_BINARY|O_RDONLY);
+ file = BLI_open(filepath_tx,O_BINARY|O_RDONLY,0);
if(file < 0) return NULL;
ibuf=IMB_loadifffile(file, flags|IB_test|IB_multilayer, filepath_tx);
@@ -195,7 +195,7 @@ void imb_loadtile(ImBuf *ibuf, int tx, int ty, unsigned int *rect)
{
int file;
- file = open(ibuf->cachename, O_BINARY|O_RDONLY);
+ file = BLI_open(ibuf->cachename, O_BINARY|O_RDONLY, 0);
if(file < 0) return;
imb_loadtilefile(ibuf, file, tx, ty, rect);
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index b5552a174a9..1801c1a8ef9 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -268,7 +268,7 @@ int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags)
if (ibuf->planes==32) {
buf[17] |= 0x08;
}
- fildes = fopen(name,"wb");
+ fildes = BLI_fopen(name,"wb");
if (!fildes) return 0;
if (fwrite(buf, 1, 18,fildes) != 18) {
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index fdc9e50bcd8..be716870dad 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -61,6 +61,7 @@
#include <process.h> /* getpid */
#include <direct.h> /* chdir */
#include "BLI_winstuff.h"
+#include "utfconv.h"
#else
#include <unistd.h>
#endif
@@ -70,8 +71,12 @@
static int get_thumb_dir( char* dir , ThumbSize size)
{
#ifdef WIN32
+ wchar_t dir_16 [MAX_PATH];
/* yes, applications shouldn't store data there, but so does GIMP :)*/
- SHGetSpecialFolderPath(0, dir, CSIDL_PROFILE, 0);
+ SHGetSpecialFolderPathW(0, dir_16, CSIDL_PROFILE, 0);
+ conv_utf_16_to_8(dir_16,dir,FILE_MAX);
+
+
#else
const char* home = getenv("HOME");
if (!home) return 0;
diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c
index 1068eccc6e0..fd0be89df0d 100644
--- a/source/blender/imbuf/intern/thumbs_blend.c
+++ b/source/blender/imbuf/intern/thumbs_blend.c
@@ -30,6 +30,7 @@
#include "zlib.h"
#include "BLI_utildefines.h"
+#include "BLI_fileops.h"
#include "BKE_utildefines.h"
#include "BKE_global.h"
@@ -123,9 +124,8 @@ static ImBuf *loadblend_thumb(gzFile gzfile)
ImBuf *IMB_loadblend_thumb(const char *path)
{
gzFile gzfile;
-
/* not necessarily a gzip */
- gzfile = gzopen(path, "rb");
+ gzfile = BLI_gzopen(path, "rb");
if (NULL == gzfile ) {
return NULL;
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index b7eba1002c5..fdcc0641628 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -159,7 +159,7 @@ static int IMB_ispic_name(const char *name)
if(((st.st_mode) & S_IFMT) != S_IFREG)
return FALSE;
- if((fp = open(name,O_BINARY|O_RDONLY)) < 0)
+ if((fp = BLI_open(name,O_BINARY|O_RDONLY, 0)) < 0)
return FALSE;
if(read(fp, buf, 32) != 32) {
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 31a50a6a16b..2ccae9671b3 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -184,7 +184,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
// ------------------------------------------------
// get numverts + numfaces first
// ------------------------------------------------
- gzf = gzopen(filename, "rb");
+ gzf = BLI_gzopen(filename, "rb");
if (!gzf)
{
return NULL;
@@ -216,7 +216,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
if(!numfaces || !numverts || !gotBytes)
return NULL;
- gzf = gzopen(filename, "rb");
+ gzf = BLI_gzopen(filename, "rb");
if (!gzf)
{
return NULL;
@@ -409,7 +409,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
filename[len-5] = 'e';
filename[len-4] = 'l';
- gzf = gzopen(filename, "rb");
+ gzf = BLI_gzopen(filename, "rb");
if (!gzf)
{
MEM_freeN(fss->meshVelocities);
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 52272bdb697..f3d21c74080 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -52,6 +52,7 @@
#include "DNA_text_types.h"
#include "BLI_path_util.h"
+#include "BLI_fileops.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
@@ -388,7 +389,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text,
}
else {
- FILE *fp = fopen(fn, "r");
+ FILE *fp = BLI_fopen(fn, "r");
if (fp) {
py_dict = PyC_DefaultNameSpace(fn);
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
index 839963e12b9..6b625d1a59a 100644
--- a/source/blender/render/intern/source/voxeldata.c
+++ b/source/blender/render/intern/source/voxeldata.c
@@ -342,7 +342,7 @@ void cache_voxeldata(Tex *tex, int scene_frame)
case TEX_VD_BLENDERVOXEL:
BLI_path_abs(path, G.main->name);
if (!BLI_exists(path)) return;
- fp = fopen(path,"rb");
+ fp = BLI_fopen(path,"rb");
if (!fp) return;
if(read_voxeldata_header(fp, vd))
@@ -353,7 +353,7 @@ void cache_voxeldata(Tex *tex, int scene_frame)
case TEX_VD_RAW_8BIT:
BLI_path_abs(path, G.main->name);
if (!BLI_exists(path)) return;
- fp = fopen(path,"rb");
+ fp = BLI_fopen(path,"rb");
if (!fp) return;
load_frame_raw8(vd, fp, curframe);
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index 521074463e0..2a1a1d5649d 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -136,4 +136,10 @@ if(WITH_BUILDINFO)
add_definitions(-DWITH_BUILDINFO)
endif()
+if(WIN322)
+ list(APPEND INC
+ ../../../intern/utfconv
+ )
+endif()
+
blender_add_lib_nolist(bf_windowmanager "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/windowmanager/SConscript b/source/blender/windowmanager/SConscript
index be037452284..ddb61d721cc 100644
--- a/source/blender/windowmanager/SConscript
+++ b/source/blender/windowmanager/SConscript
@@ -32,6 +32,7 @@ if env['OURPLATFORM'] == 'linux':
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
incs += ' ' + env['BF_PTHREADS_INC']
+ incs += ' ../../intern/utfconv'
if env['OURPLATFORM'] != 'darwin' or env['WITH_GHOST_COCOA']:
sources.remove('intern' + os.sep + 'wm_apple.c')
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 1e2c48f4e7f..5384d6ef8f7 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -304,6 +304,7 @@ static void wm_init_userdef(bContext *C)
#define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */
#define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */
+
/* intended to check for non-blender formats but for now it only reads blends */
static int wm_read_exotic(Scene *UNUSED(scene), const char *name)
{
@@ -319,8 +320,7 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name)
retval= BKE_READ_EXOTIC_FAIL_PATH;
}
else {
- gzfile = gzopen(name,"rb");
-
+ gzfile = BLI_gzopen(name,"rb");
if (gzfile == NULL) {
retval= BKE_READ_EXOTIC_FAIL_OPEN;
}
@@ -627,7 +627,7 @@ static void write_history(void)
recent = G.recent_files.first;
/* refresh recent-files.txt of recent opened files, when current file was changed */
if(!(recent) || (BLI_path_cmp(recent->filepath, G.main->name)!=0)) {
- fp= fopen(name, "w");
+ fp= BLI_fopen(name, "w");
if (fp) {
/* add current file to the beginning of list */
recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile");