forked from bartvdbraak/blender
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.
This commit is contained in:
parent
a5e1ff294e
commit
86336f5cdd
@ -311,9 +311,9 @@ void BLI_recurdir_fileops(char *dirname) {
|
||||
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 @@ void BLI_recurdir_fileops(char *dirname) {
|
||||
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);
|
||||
}
|
||||
|
@ -501,6 +501,8 @@ static void renamebutton_cb(bContext *C, void *arg1, char *oldname)
|
||||
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 @@ static void renamebutton_cb(bContext *C, void *arg1, char *oldname)
|
||||
BLI_make_file_string(G.sce, newname, sfile->params->dir, filename);
|
||||
|
||||
if( strcmp(orgname, newname) != 0 ) {
|
||||
if (!BLI_exists(newname)) {
|
||||
BLI_rename(orgname, newname);
|
||||
|
||||
/* to refresh the file list, does sorting again */
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user