Cleanup: style, use braces for blenkernel
[blender.git] / source / blender / blenkernel / intern / appdir.c
index 5383138..0986596 100644 (file)
@@ -73,8 +73,9 @@ const char *BKE_appdir_folder_default(void)
 #ifndef WIN32
   const char *const xdg_documents_dir = BLI_getenv("XDG_DOCUMENTS_DIR");
 
-  if (xdg_documents_dir)
+  if (xdg_documents_dir) {
     return xdg_documents_dir;
+  }
 
   return BLI_getenv("HOME");
 #else  /* Windows */
@@ -83,8 +84,9 @@ const char *BKE_appdir_folder_default(void)
 
   /* Check for %HOME% env var */
   if (uput_getenv("HOME", documentfolder, MAXPATHLEN)) {
-    if (BLI_is_dir(documentfolder))
+    if (BLI_is_dir(documentfolder)) {
       return documentfolder;
+    }
   }
 
   /* add user profile support for WIN 2K / NT.
@@ -95,8 +97,9 @@ const char *BKE_appdir_folder_default(void)
   hResult = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, documentfolder);
 
   if (hResult == S_OK) {
-    if (BLI_is_dir(documentfolder))
+    if (BLI_is_dir(documentfolder)) {
       return documentfolder;
+    }
   }
 
   return NULL;
@@ -165,8 +168,9 @@ static bool test_path(char *targetpath,
 static bool test_env_path(char *path, const char *envvar)
 {
   const char *env = envvar ? BLI_getenv(envvar) : NULL;
-  if (!env)
+  if (!env) {
     return false;
+  }
 
   if (BLI_is_dir(env)) {
     BLI_strncpy(path, env, FILE_MAX);
@@ -324,11 +328,13 @@ static bool get_path_user(char *targetpath,
   user_path[0] = '\0';
 
   user_base_path = (const char *)GHOST_getUserDir(ver, blender_version_decimal(ver));
-  if (user_base_path)
+  if (user_base_path) {
     BLI_strncpy(user_path, user_base_path, FILE_MAX);
+  }
 
-  if (!user_path[0])
+  if (!user_path[0]) {
     return false;
+  }
 
 #ifdef PATH_DEBUG
   printf("%s: %s\n", __func__, user_path);
@@ -375,11 +381,13 @@ static bool get_path_system(char *targetpath,
 
   system_path[0] = '\0';
   system_base_path = (const char *)GHOST_getSystemDir(ver, blender_version_decimal(ver));
-  if (system_base_path)
+  if (system_base_path) {
     BLI_strncpy(system_path, system_base_path, FILE_MAX);
+  }
 
-  if (!system_path[0])
+  if (!system_path[0]) {
     return false;
+  }
 
 #ifdef PATH_DEBUG
   printf("%s: %s\n", __func__, system_path);
@@ -411,71 +419,93 @@ const char *BKE_appdir_folder_id_ex(const int folder_id,
 
   switch (folder_id) {
     case BLENDER_DATAFILES: /* general case */
-      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES"))
+      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES")) {
         break;
-      if (get_path_user(path, path_len, "datafiles", subfolder, ver))
+      }
+      if (get_path_user(path, path_len, "datafiles", subfolder, ver)) {
         break;
-      if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES"))
+      }
+      if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES")) {
         break;
-      if (get_path_local(path, path_len, "datafiles", subfolder, ver))
+      }
+      if (get_path_local(path, path_len, "datafiles", subfolder, ver)) {
         break;
-      if (get_path_system(path, path_len, "datafiles", subfolder, ver))
+      }
+      if (get_path_system(path, path_len, "datafiles", subfolder, ver)) {
         break;
+      }
       return NULL;
 
     case BLENDER_USER_DATAFILES:
-      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES"))
+      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES")) {
         break;
-      if (get_path_user(path, path_len, "datafiles", subfolder, ver))
+      }
+      if (get_path_user(path, path_len, "datafiles", subfolder, ver)) {
         break;
+      }
       return NULL;
 
     case BLENDER_SYSTEM_DATAFILES:
-      if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES"))
+      if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES")) {
         break;
-      if (get_path_system(path, path_len, "datafiles", subfolder, ver))
+      }
+      if (get_path_system(path, path_len, "datafiles", subfolder, ver)) {
         break;
-      if (get_path_local(path, path_len, "datafiles", subfolder, ver))
+      }
+      if (get_path_local(path, path_len, "datafiles", subfolder, ver)) {
         break;
+      }
       return NULL;
 
     case BLENDER_USER_AUTOSAVE:
-      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES"))
+      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES")) {
         break;
-      if (get_path_user(path, path_len, "autosave", subfolder, ver))
+      }
+      if (get_path_user(path, path_len, "autosave", subfolder, ver)) {
         break;
+      }
       return NULL;
 
     case BLENDER_USER_CONFIG:
-      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_CONFIG"))
+      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_CONFIG")) {
         break;
-      if (get_path_user(path, path_len, "config", subfolder, ver))
+      }
+      if (get_path_user(path, path_len, "config", subfolder, ver)) {
         break;
+      }
       return NULL;
 
     case BLENDER_USER_SCRIPTS:
-      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_SCRIPTS"))
+      if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_SCRIPTS")) {
         break;
-      if (get_path_user(path, path_len, "scripts", subfolder, ver))
+      }
+      if (get_path_user(path, path_len, "scripts", subfolder, ver)) {
         break;
+      }
       return NULL;
 
     case BLENDER_SYSTEM_SCRIPTS:
-      if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_SCRIPTS"))
+      if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_SCRIPTS")) {
         break;
-      if (get_path_system(path, path_len, "scripts", subfolder, ver))
+      }
+      if (get_path_system(path, path_len, "scripts", subfolder, ver)) {
         break;
-      if (get_path_local(path, path_len, "scripts", subfolder, ver))
+      }
+      if (get_path_local(path, path_len, "scripts", subfolder, ver)) {
         break;
+      }
       return NULL;
 
     case BLENDER_SYSTEM_PYTHON:
-      if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_PYTHON"))
+      if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_PYTHON")) {
         break;
-      if (get_path_system(path, path_len, "python", subfolder, ver))
+      }
+      if (get_path_system(path, path_len, "python", subfolder, ver)) {
         break;
-      if (get_path_local(path, path_len, "python", subfolder, ver))
+      }
+      if (get_path_local(path, path_len, "python", subfolder, ver)) {
         break;
+      }
       return NULL;
 
     default:
@@ -502,23 +532,27 @@ const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char *su
 
   switch (folder_id) {
     case BLENDER_USER_DATAFILES:
-      if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_DATAFILES"))
+      if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_DATAFILES")) {
         break;
+      }
       get_path_user(path, sizeof(path), "datafiles", subfolder, ver);
       break;
     case BLENDER_USER_CONFIG:
-      if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_CONFIG"))
+      if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_CONFIG")) {
         break;
+      }
       get_path_user(path, sizeof(path), "config", subfolder, ver);
       break;
     case BLENDER_USER_AUTOSAVE:
-      if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_AUTOSAVE"))
+      if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_AUTOSAVE")) {
         break;
+      }
       get_path_user(path, sizeof(path), "autosave", subfolder, ver);
       break;
     case BLENDER_USER_SCRIPTS:
-      if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_SCRIPTS"))
+      if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_SCRIPTS")) {
         break;
+      }
       get_path_user(path, sizeof(path), "scripts", subfolder, ver);
       break;
     default:
@@ -544,15 +578,17 @@ const char *BKE_appdir_folder_id_create(const int folder_id, const char *subfold
             BLENDER_USER_DATAFILES,
             BLENDER_USER_CONFIG,
             BLENDER_USER_SCRIPTS,
-            BLENDER_USER_AUTOSAVE))
+            BLENDER_USER_AUTOSAVE)) {
     return NULL;
+  }
 
   path = BKE_appdir_folder_id(folder_id, subfolder);
 
   if (!path) {
     path = BKE_appdir_folder_id_user_notest(folder_id, subfolder);
-    if (path)
+    if (path) {
       BLI_dir_create_recursive(path);
+    }
   }
 
   return path;