Cleanup: better naming and no bad level access in BLI_winstuff
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user