[Bf-blender-cvs] [651102170c] app-templates: Use BLI_path_name_at_index
Campbell Barton
noreply at git.blender.org
Wed Mar 22 19:52:04 CET 2017
Commit: 651102170c7f2006609cf136da473583064206ca
Author: Campbell Barton
Date: Wed Mar 22 19:38:16 2017 +1100
Branches: app-templates
https://developer.blender.org/rB651102170c7f2006609cf136da473583064206ca
Use BLI_path_name_at_index
===================================================================
M source/blender/windowmanager/intern/wm_files.c
===================================================================
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index e82292664a..0e5f04df54 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -421,18 +421,18 @@ void WM_file_autoexec_init(const char *filepath)
}
}
-static void wm_file_template_from_path(char app_template[sizeof(U.app_template)], const char *filepath)
-{
- const char *end = BLI_last_slash(filepath);
- const char *sta = end;
- while (sta > filepath) {
- sta--;
- if (ELEM(*sta, SEP, ALTSEP)) {
- sta++;
- break;
+static bool wm_file_template_from_path(char app_template[sizeof(U.app_template)], const char *filepath)
+{
+ int offset, len;
+ if (BLI_path_name_at_index(filepath, -2, &offset, &len)) {
+ if (len < sizeof(U.app_template)) {
+ memcpy(app_template, &filepath[offset], len);
+ app_template[len] = '\0';
+ printf("APP '%s'\n", app_template);
+ return true;
}
}
- BLI_strncpy(app_template, sta, MIN2((end - sta) + 1, sizeof(U.app_template)));
+ return false;
}
void wm_file_read_report(bContext *C)
@@ -1489,8 +1489,8 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
const bool use_splash = !from_memory && RNA_boolean_get(op->ptr, "use_splash");
if (is_app_template) {
- if (filepath != NULL) {
- wm_file_template_from_path(app_template_buf, filepath);
+ if ((filepath != NULL) && wm_file_template_from_path(app_template_buf, filepath)) {
+ /* pass */
}
else {
app_template_buf[0] = '\0';
More information about the Bf-blender-cvs
mailing list