[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21983] branches/blender2.5/blender/source /blender: 2.5 file browser

Andrea Weikert elubie at gmx.net
Tue Jul 28 20:07:00 CEST 2009


Revision: 21983
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21983
Author:   elubie
Date:     2009-07-28 20:07:00 +0200 (Tue, 28 Jul 2009)

Log Message:
-----------
2.5 file browser
Bugfix: revert to previous behaviour of BLI_rename, is used for safe blendfile saving.
Added guard in file browser though to prevent user from invoking this.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenlib/intern/fileops.c
    branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c

Modified: branches/blender2.5/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/fileops.c	2009-07-28 17:59:59 UTC (rev 21982)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/fileops.c	2009-07-28 18:07:00 UTC (rev 21983)
@@ -311,9 +311,9 @@
 int BLI_rename(char *from, char *to) {
 	if (!BLI_exists(from)) return 0;
 
-	/* refuse to rename if file already exists */
-	if (BLI_exists(to))
-		return 1; 
+	/* make sure the filenames are different (case insensitive) before removing */
+	if (BLI_exists(to) && BLI_strcasecmp(from, to))
+		if(BLI_delete(to, 0, 0)) return 1;
 
 	return rename(from, to);
 }
@@ -391,8 +391,7 @@
 int BLI_rename(char *from, char *to) {
 	if (!BLI_exists(from)) return 0;
 	
-	/* refuse to rename if file already exists */
-	if (BLI_exists(to)) return 1;
+	if (BLI_exists(to))	if(BLI_delete(to, 0, 0)) return 1;
 
 	return rename(from, to);
 }

Modified: branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c	2009-07-28 17:59:59 UTC (rev 21982)
+++ branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c	2009-07-28 18:07:00 UTC (rev 21983)
@@ -501,6 +501,8 @@
 	char orgname[FILE_MAX+12];
 	char filename[FILE_MAX+12];
 	SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+	ARegion* ar = CTX_wm_region(C);
+
 	struct direntry *file = (struct direntry *)arg1;
 
 	BLI_make_file_string(G.sce, orgname, sfile->params->dir, oldname);
@@ -508,10 +510,15 @@
 	BLI_make_file_string(G.sce, newname, sfile->params->dir, filename);
 
 	if( strcmp(orgname, newname) != 0 ) {
-		BLI_rename(orgname, newname);
-
-		/* to refresh the file list, does sorting again */
-		filelist_free(sfile->files);
+		if (!BLI_exists(newname)) {
+			BLI_rename(orgname, newname);
+			/* to make sure we show what is on disk */
+			filelist_free(sfile->files);
+		} else {
+			BLI_strncpy(file->relname, oldname, strlen(oldname)+1);
+		}
+		
+		ED_region_tag_redraw(ar);
 	}
 }
 





More information about the Bf-blender-cvs mailing list