diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-08-27 08:49:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-08-27 08:49:22 +0300 |
commit | 94884777b20dc612863690171b958eef41a4b6fd (patch) | |
tree | 975cb00d99180ae474c79b9187bcedf4d174bcc9 /source/blender/blenlib | |
parent | 0659560a101bd450725702714f474b2b8baf19a0 (diff) | |
parent | 54b47da56596298a6d880d334a2c403862855ae9 (diff) |
Merge branch 'master' into newboolean
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_array.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_winstuff.h | 12 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/winstuff.c | 52 |
4 files changed, 24 insertions, 48 deletions
diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index 6ea01d45f79..4e37314ed3e 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -117,7 +117,7 @@ void _bli_array_grow_func(void **arr_p, { \ if (arr && (char *)arr != _##arr##_static) { \ BLI_array_fake_user(arr); \ - MEM_freeN(arr); \ + MEM_freeN((void *)arr); \ } \ } \ ((void)0) diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index 2de6098f6be..8076724a214 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -28,6 +28,8 @@ # error "This include is for Windows only!" #endif +#include "BLI_sys_types.h" + #define WIN32_LEAN_AND_MEAN #include <windows.h> @@ -86,6 +88,7 @@ typedef long ssize_t; # endif #endif +/* Directory reading compatibility with UNIX. */ struct dirent { int d_ino; int d_off; @@ -99,13 +102,12 @@ typedef struct __dirstream DIR; DIR *opendir(const char *path); struct dirent *readdir(DIR *dp); int closedir(DIR *dp); - -void RegisterBlendExtension(void); -void get_default_root(char *root); -int check_file_chars(char *filename); const char *dirname(char *path); -int BLI_getInstallationDir(char *str); +/* Windows utility functions. */ +void BLI_windows_register_blend_extension(const bool background); +void BLI_windows_get_default_root_dir(char *root_dir); +int BLI_windows_get_executable_dir(char *str); #ifdef __cplusplus } diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 67d41ffb779..cde4394a8c3 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -532,7 +532,7 @@ void BLI_path_rel(char *file, const char *relfile) char *ptemp; /* fix missing volume name in relative base, * can happen with old recent-files.txt files */ - get_default_root(temp); + BLI_windows_get_default_root_dir(temp); ptemp = &temp[2]; if (relfile[0] != '\\' && relfile[0] != '/') { ptemp++; @@ -1026,7 +1026,7 @@ bool BLI_path_abs(char *path, const char *basepath) */ if (!wasrelative && !BLI_path_is_abs(path)) { char *p = path; - get_default_root(tmp); + BLI_windows_get_default_root_dir(tmp); // get rid of the slashes at the beginning of the path while (ELEM(*p, '\\', '/')) { p++; @@ -1385,7 +1385,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c string[3] = '\0'; } else { /* we're out of luck here, guessing the first valid drive, usually c:\ */ - get_default_root(string); + BLI_windows_get_default_root_dir(string); } /* ignore leading slashes */ diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index df7e7107d11..333b6783087 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -36,14 +36,12 @@ # include "BLI_utildefines.h" # include "BLI_winstuff.h" -# include "../blenkernel/BKE_global.h" /* G.background, bad level include (no function calls) */ - # include "utf_winfunc.h" # include "utfconv.h" /* FILE_MAXDIR + FILE_MAXFILE */ -int BLI_getInstallationDir(char *str) +int BLI_windows_get_executable_dir(char *str) { char dir[FILE_MAXDIR]; int a; @@ -60,19 +58,19 @@ int BLI_getInstallationDir(char *str) return 1; } -static void RegisterBlendExtension_Fail(HKEY root) +static void register_blend_extension_failed(HKEY root, const bool background) { printf("failed\n"); if (root) { RegCloseKey(root); } - if (!G.background) { + if (!background) { MessageBox(0, "Could not register file extension.", "Blender error", MB_OK | MB_ICONERROR); } TerminateProcess(GetCurrentProcess(), 1); } -void RegisterBlendExtension(void) +void BLI_windows_register_blend_extension(const bool background) { LONG lresult; HKEY hkey = 0; @@ -108,7 +106,7 @@ void RegisterBlendExtension(void) usr_mode = true; lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) { - RegisterBlendExtension_Fail(0); + register_blend_extension_failed(0, background); } } @@ -120,7 +118,7 @@ void RegisterBlendExtension(void) RegCloseKey(hkey); } if (lresult != ERROR_SUCCESS) { - RegisterBlendExtension_Fail(root); + register_blend_extension_failed(root, background); } lresult = RegCreateKeyEx(root, @@ -138,7 +136,7 @@ void RegisterBlendExtension(void) RegCloseKey(hkey); } if (lresult != ERROR_SUCCESS) { - RegisterBlendExtension_Fail(root); + register_blend_extension_failed(root, background); } lresult = RegCreateKeyEx(root, @@ -156,7 +154,7 @@ void RegisterBlendExtension(void) RegCloseKey(hkey); } if (lresult != ERROR_SUCCESS) { - RegisterBlendExtension_Fail(root); + register_blend_extension_failed(root, background); } lresult = RegCreateKeyEx( @@ -167,10 +165,10 @@ void RegisterBlendExtension(void) RegCloseKey(hkey); } if (lresult != ERROR_SUCCESS) { - RegisterBlendExtension_Fail(root); + register_blend_extension_failed(root, background); } - BLI_getInstallationDir(InstallDir); + BLI_windows_get_executable_dir(InstallDir); GetSystemDirectory(SysDir, FILE_MAXDIR); ThumbHandlerDLL = "BlendThumb.dll"; snprintf( @@ -179,7 +177,7 @@ void RegisterBlendExtension(void) RegCloseKey(root); printf("success (%s)\n", usr_mode ? "user" : "system"); - if (!G.background) { + if (!background) { sprintf(MBox, "File extension registered for %s.", usr_mode ? "the current user. To register for all users, run as an administrator" : @@ -189,7 +187,7 @@ void RegisterBlendExtension(void) TerminateProcess(GetCurrentProcess(), 0); } -void get_default_root(char *root) +void BLI_windows_get_default_root_dir(char *root) { char str[MAX_PATH + 1]; @@ -236,7 +234,7 @@ void get_default_root(char *root) } } if (0 == rc) { - printf("ERROR in 'get_default_root': can't find a valid drive!\n"); + printf("ERROR in 'BLI_windows_get_default_root_dir': can't find a valid drive!\n"); root[0] = 'C'; root[1] = ':'; root[2] = '\\'; @@ -246,30 +244,6 @@ void get_default_root(char *root) } } -/* UNUSED */ -# if 0 -int check_file_chars(char *filename) -{ - char *p = filename; - while (*p) { - switch (*p) { - case ':': - case '?': - case '*': - case '|': - case '\\': - case '/': - case '\"': - return 0; - break; - } - - p++; - } - return 1; -} -# endif - #else /* intentionally empty for UNIX */ |