diff options
author | Alexander Kuznetsov <kuzsasha@gmail.com> | 2012-03-20 06:17:37 +0400 |
---|---|---|
committer | Alexander Kuznetsov <kuzsasha@gmail.com> | 2012-03-20 06:17:37 +0400 |
commit | f11a6d3a847e8e18faefd8694373d2f11b5ec802 (patch) | |
tree | b4bec6dcfd28e3da4fa1e84ee4bd20fa0a21be39 /source/creator | |
parent | deea1f38b1ec0ccba283abeb63506cbc15e093d5 (diff) |
Adds support for utf paths on Windows.
Not all file formats/calls are supported yet. It will be expended.
Please from now on use BLI_fopen, BLI_* for file manipulations.
For non-windows systems BLI_fopen just calls fopen.
For Windows, the utf-8 string is translated to utf-16 string in order to call UTF version of the function.
Diffstat (limited to 'source/creator')
-rw-r--r-- | source/creator/CMakeLists.txt | 5 | ||||
-rw-r--r-- | source/creator/creator.c | 32 |
2 files changed, 37 insertions, 0 deletions
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index a4aec7d7ba3..57c62db3117 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -40,6 +40,10 @@ blender_include_dirs( ../blender/windowmanager ) +if(WIN32) + blender_include_dirs(../../intern/utfconv) +endif() + if(WITH_LIBMV) blender_include_dirs(../../extern/libmv) add_definitions(-DWITH_LIBMV) @@ -823,6 +827,7 @@ endif() bf_intern_memutil bf_intern_guardedalloc bf_intern_ctr + bf_intern_utfconv ge_blen_routines ge_converter ge_phys_dummy diff --git a/source/creator/creator.c b/source/creator/creator.c index eb5761bb095..63e25e1d820 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -40,6 +40,11 @@ #include <xmmintrin.h> #endif +#ifdef WIN32 +#include <Windows.h> +#include "utfconv.h" +#endif + #include <stdlib.h> #include <stddef.h> #include <string.h> @@ -1109,12 +1114,28 @@ char **environ = NULL; #endif + +#ifdef WIN32 +int main(int argc, const char **argv_c) /*Do not mess with const*/ +#else int main(int argc, const char **argv) +#endif { SYS_SystemHandle syshandle; bContext *C= CTX_create(); bArgs *ba; +#ifdef WIN32 + wchar_t ** argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc); + int argci = 0; + char ** argv = MEM_mallocN(argc * sizeof(char*),"argv array"); + for(argci=0; argci<argc; argci++) + { + argv[argci] = alloc_utf_8_from_16(argv_16[argci],0); + } + LocalFree(argv_16); +#endif + #ifdef WITH_PYTHON_MODULE #ifdef __APPLE__ environ = *_NSGetEnviron(); @@ -1124,6 +1145,8 @@ int main(int argc, const char **argv) evil_C= C; #endif + + #ifdef WITH_BINRELOC br_init( NULL ); #endif @@ -1245,6 +1268,15 @@ int main(int argc, const char **argv) BLI_argsFree(ba); +#ifdef WIN32 + while(argci) + { + free(argv[--argci]); + } + MEM_freeN(argv); + argv = NULL; +#endif + #ifdef WITH_PYTHON_MODULE return 0; /* keep blender in background mode running */ #endif |