[Bf-blender-cvs] [6b76381e0a5] master: Cleanup: rename BKE_appdir_folder_id_version, improve doc-strings
Campbell Barton
noreply at git.blender.org
Tue Oct 4 07:58:22 CEST 2022
Commit: 6b76381e0a52cf15513087e470a4a4c07471acc6
Author: Campbell Barton
Date: Tue Oct 4 16:52:10 2022 +1100
Branches: master
https://developer.blender.org/rB6b76381e0a52cf15513087e470a4a4c07471acc6
Cleanup: rename BKE_appdir_folder_id_version, improve doc-strings
Rename BKE_appdir_folder_id_version to
BKE_appdir_resource_path_id_with_version because BKE_appdir_folder_id
and BKE_appdir_folder_id_version didn't accept compatible arguments.
Also add notes to GHOST_getSystemDir & GHOST_getUserDir that
BKE_appdir_resource_path_id(..) should be used instead (in most cases).
===================================================================
M intern/ghost/GHOST_Path-api.h
M source/blender/blenkernel/BKE_appdir.h
M source/blender/blenkernel/intern/appdir.c
M source/blender/python/intern/bpy.c
===================================================================
diff --git a/intern/ghost/GHOST_Path-api.h b/intern/ghost/GHOST_Path-api.h
index d303654d3e6..42c7cc75668 100644
--- a/intern/ghost/GHOST_Path-api.h
+++ b/intern/ghost/GHOST_Path-api.h
@@ -30,13 +30,19 @@ extern GHOST_TSuccess GHOST_DisposeSystemPaths(void);
/**
* Determine the base dir in which shared resources are located. It will first try to use
* "unpack and run" path, then look for properly installed path, including versioning.
- * \return Unsigned char string pointing to system dir (eg /usr/share/blender/).
+ * \return Unsigned char string pointing to system dir (eg `/usr/share/blender/`).
+ *
+ * \note typically: `BKE_appdir_resource_path_id(BLENDER_RESOURCE_PATH_SYSTEM, false)` should be
+ * used instead of this function directly as it ensures environment variable overrides are used.
*/
extern const char *GHOST_getSystemDir(int version, const char *versionstr);
/**
* Determine the base dir in which user configuration is stored, including versioning.
* \return Unsigned char string pointing to user dir (eg ~).
+ *
+ * \note typically: `BKE_appdir_resource_path_id(BLENDER_RESOURCE_PATH_USER, false)` should be
+ * used instead of this function directly as it ensures environment variable overrides are used.
*/
extern const char *GHOST_getUserDir(int version, const char *versionstr);
diff --git a/source/blender/blenkernel/BKE_appdir.h b/source/blender/blenkernel/BKE_appdir.h
index 0f00ab9c321..a67c6c27b47 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -90,7 +90,10 @@ const char *BKE_appdir_folder_id_user_notest(int folder_id,
* Returns the path of the top-level version-specific local, user or system directory.
* If check_is_dir, then the result will be NULL if the directory doesn't exist.
*/
-const char *BKE_appdir_folder_id_version(int folder_id, int version, bool check_is_dir);
+const char *BKE_appdir_resource_path_id_with_version(int folder_id,
+ bool check_is_dir,
+ int version);
+const char *BKE_appdir_resource_path_id(int folder_id, bool check_is_dir);
/**
* Check if this is an install with user files kept together
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 7c409f1095b..b2f1e75cd1d 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -760,9 +760,9 @@ const char *BKE_appdir_folder_id_create(const int folder_id, const char *subfold
return path;
}
-const char *BKE_appdir_folder_id_version(const int folder_id,
- const int version,
- const bool check_is_dir)
+const char *BKE_appdir_resource_path_id_with_version(const int folder_id,
+ const bool check_is_dir,
+ const int version)
{
static char path[FILE_MAX] = "";
bool ok;
@@ -785,6 +785,11 @@ const char *BKE_appdir_folder_id_version(const int folder_id,
return ok ? path : NULL;
}
+const char *BKE_appdir_resource_path_id(const int folder_id, const bool check_is_dir)
+{
+ return BKE_appdir_resource_path_id_with_version(folder_id, check_is_dir, BLENDER_VERSION);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 3b3ffb321c3..861b4dddff9 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -322,7 +322,7 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
return NULL;
}
- path = BKE_appdir_folder_id_version(type.value_found, (major * 100) + minor, false);
+ path = BKE_appdir_resource_path_id_with_version(type.value_found, (major * 100) + minor, false);
return PyC_UnicodeFromByte(path ? path : "");
}
More information about the Bf-blender-cvs
mailing list