diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-09-21 01:11:38 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-09-21 01:11:38 +0400 |
commit | 2ac17c4c23c22dfdb0f1b34fd05c3cb4fa58f4f9 (patch) | |
tree | a7548befd5e4d2c0a8656c2da07957b65fd58697 /source/blender | |
parent | aff24bdc077c36945db22e2c3f88d6d6302a172d (diff) |
Fix #23917: selecting a directory with the file browser didn't append
a slash, which is necessary for e.g. render file ouput.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_ops.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index c4357008a9c..c1803dde805 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -33,8 +33,12 @@ #include "DNA_userdef_types.h" #include "BLI_fileops.h" +#include "BLI_path_util.h" +#include "BLI_storage.h" +#include "BLI_string.h" #include "BKE_context.h" +#include "BKE_global.h" #include "WM_api.h" #include "WM_types.h" @@ -89,12 +93,28 @@ typedef struct FileBrowseOp { static int file_browse_exec(bContext *C, wmOperator *op) { FileBrowseOp *fbo= op->customdata; - char *str; + ID *id; + char *base, *str, path[FILE_MAX]; if (RNA_property_is_set(op->ptr, "filepath")==0 || fbo==NULL) return OPERATOR_CANCELLED; str= RNA_string_get_alloc(op->ptr, "filepath", 0, 0); + + /* add slash for directories, important for some properties */ + if(RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { + id = fbo->ptr.id.data; + base = (id && id->lib)? id->lib->filepath: G.sce; + + BLI_strncpy(path, str, FILE_MAX); + BLI_path_abs(path, base); + + if(BLI_is_dir(path)) { + str = MEM_reallocN(str, strlen(str)+2); + BLI_add_slash(str); + } + } + RNA_property_string_set(&fbo->ptr, fbo->prop, str); RNA_property_update(C, &fbo->ptr, fbo->prop); MEM_freeN(str); |