diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-17 19:11:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-17 19:11:12 +0400 |
commit | 6717b75ecdd7d9702b280dc3fccccc172e261d38 (patch) | |
tree | da566cc4db87325bfb8b349d414f3c0a62489805 | |
parent | 84dc5a3b94d033466692f6c878c6cb9054114fdc (diff) |
bugfix [#23783] /../ prefix stops going up a dir
also fix for recent addition to operator check(), when the file selector is loaded with no operator.
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 36 |
2 files changed, 31 insertions, 20 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index cf773d575e5..50c5095afe7 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -311,10 +311,17 @@ void BLI_cleanup_file(const char *relabase, char *dir) dir[0]= '/'; dir[1]= 0; return; - } + } + + /* support for odd paths: eg /../home/me --> /home/me + * this is a valid path in blender but we cant handle this the useual way below + * simply strip this prefix then evaluate the path as useual. pythons os.path.normpath() does this */ + while((strncmp(dir, "/../", 4)==0)) { + memmove( dir, dir + 4, strlen(dir + 4) + 1 ); + } while ( (start = strstr(dir, "/../")) ) { - eind = start + strlen("/../") - 1; + eind = start + (4 - 1) /* strlen("/../") - 1 */; a = start-dir-1; while (a>0) { if (dir[a] == '/') break; @@ -328,12 +335,12 @@ void BLI_cleanup_file(const char *relabase, char *dir) } while ( (start = strstr(dir,"/./")) ){ - eind = start + strlen("/./") - 1; + eind = start + (3 - 1) /* strlen("/./") - 1 */; memmove( start, eind, strlen(eind)+1 ); } while ( (start = strstr(dir,"//" )) ){ - eind = start + strlen("//") - 1; + eind = start + (2 - 1) /* strlen("//") - 1 */; memmove( start, eind, strlen(eind)+1 ); } diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index c3e9e22eaad..9393f1c4d6d 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -624,28 +624,32 @@ void file_draw_check_cb(bContext *C, void *dummy1, void *dummy2) { SpaceFile *sfile= CTX_wm_space_file(C); wmOperator *op= sfile->op; - if(op->type->check) { - char filepath[FILE_MAX]; - file_sfile_to_operator(op, sfile, filepath); - - /* redraw */ - if(op->type->check(C, op)) { - file_operator_to_sfile(sfile, op); - - /* redraw, else the changed settings wont get updated */ - ED_area_tag_redraw(CTX_wm_area(C)); + if(op) { /* fail on reload */ + if(op->type->check) { + char filepath[FILE_MAX]; + file_sfile_to_operator(op, sfile, filepath); + + /* redraw */ + if(op->type->check(C, op)) { + file_operator_to_sfile(sfile, op); + + /* redraw, else the changed settings wont get updated */ + ED_area_tag_redraw(CTX_wm_area(C)); + } } } } int file_draw_check_exists(SpaceFile *sfile) { - if(RNA_struct_find_property(sfile->op->ptr, "check_existing")) { - if(RNA_boolean_get(sfile->op->ptr, "check_existing")) { - char filepath[FILE_MAX]; - BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file); - if(BLI_exists(filepath) && !BLI_is_dir(filepath)) { - return TRUE; + if(sfile->op) { /* fails on reload */ + if(RNA_struct_find_property(sfile->op->ptr, "check_existing")) { + if(RNA_boolean_get(sfile->op->ptr, "check_existing")) { + char filepath[FILE_MAX]; + BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file); + if(BLI_exists(filepath) && !BLI_is_dir(filepath)) { + return TRUE; + } } } } |