[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31981] trunk/blender/source/blender: bugfix [#23783] /../ prefix stops going up a dir
Campbell Barton
ideasman42 at gmail.com
Fri Sep 17 17:12:04 CEST 2010
Revision: 31981
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31981
Author: campbellbarton
Date: 2010-09-17 17:11:12 +0200 (Fri, 17 Sep 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/path_util.c
trunk/blender/source/blender/editors/space_file/file_ops.c
Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c 2010-09-17 13:52:38 UTC (rev 31980)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c 2010-09-17 15:11:12 UTC (rev 31981)
@@ -311,10 +311,17 @@
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 @@
}
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 );
}
Modified: trunk/blender/source/blender/editors/space_file/file_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/file_ops.c 2010-09-17 13:52:38 UTC (rev 31980)
+++ trunk/blender/source/blender/editors/space_file/file_ops.c 2010-09-17 15:11:12 UTC (rev 31981)
@@ -624,28 +624,32 @@
{
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;
+ }
}
}
}
More information about the Bf-blender-cvs
mailing list