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:
authorBrecht Van Lommel <brecht@blender.org>2020-08-26 16:50:48 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-08-26 20:26:38 +0300
commitf699ba3d30ec1a5cb8d61f7522787a7b701ea9d2 (patch)
tree9e2d3c10e788f1eec685002ba87ecd28b7c7ff5e /source/blender
parent9de18c361bb4efa11016b6a6671b6409cfe5a2fb (diff)
Cleanup: better naming and no bad level access in BLI_winstuff
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/BLI_winstuff.h12
-rw-r--r--source/blender/blenlib/intern/path_util.c6
-rw-r--r--source/blender/blenlib/intern/winstuff.c52
-rw-r--r--source/blender/editors/space_file/file_ops.c2
-rw-r--r--source/blender/editors/space_file/filelist.c2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c2
6 files changed, 26 insertions, 50 deletions
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 */
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 83c0e60168b..8c4b2a1b8a6 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -2297,7 +2297,7 @@ static void file_expand_directory(bContext *C)
}
#else
{
- get_default_root(sfile->params->dir);
+ BLI_windows_get_default_root_dir(sfile->params->dir);
}
/* change "C:" --> "C:\", [#28102] */
else if ((isalpha(sfile->params->dir[0]) && (sfile->params->dir[1] == ':')) &&
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 67ea22a7ef5..0ade50814e0 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1127,7 +1127,7 @@ static void parent_dir_until_exists_or_default_root(char *dir)
{
if (!BLI_path_parent_dir_until_exists(dir)) {
#ifdef WIN32
- get_default_root(dir);
+ BLI_windows_get_default_root_dir(dir);
#else
strcpy(dir, "/");
#endif
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 62d9c099cd5..f53a3d6bf35 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1576,7 +1576,7 @@ void wm_autosave_location(char *filepath)
* Blender installed on D:\ drive, D:\ drive has D:\tmp\
* Now, BLI_exists() will find '/tmp/' exists, but
* BLI_make_file_string will create string that has it most likely on C:\
- * through get_default_root().
+ * through BLI_windows_get_default_root_dir().
* If there is no C:\tmp autosave fails. */
if (!BLI_exists(BKE_tempdir_base())) {
savedir = BKE_appdir_folder_id_create(BLENDER_USER_AUTOSAVE, NULL);