diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-09-22 19:37:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-09-22 19:37:32 +0400 |
commit | e4def00d5bc8c4b2947f74d2b5c3308ae07a4eee (patch) | |
tree | c417d2273fb5ac9aa7b89e63f7dd3212a1de4628 /source/blender/src/filesel.c | |
parent | bc151f133478dff9190fae6e63e58dc7cdbfeb75 (diff) |
fix for [#15020] File browser: going back from the root of all directories introduces "../" ad libitum + harcoded path?
bug was introduced when fixing BLI_cleanup_dir not to write to negative character indicies.
added a BLI_parent_dir(char *path)
Diffstat (limited to 'source/blender/src/filesel.c')
-rw-r--r-- | source/blender/src/filesel.c | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c index cdb001d9193..22f7e577ad9 100644 --- a/source/blender/src/filesel.c +++ b/source/blender/src/filesel.c @@ -555,54 +555,18 @@ static void split_sfile(SpaceFile *sfile, char *s1) void parent(SpaceFile *sfile) { - short a; - char *dir; + char path[sizeof(sfile->dir)+4]; /* if databrowse: no parent */ if(sfile->type==FILE_MAIN && filesel_has_func(sfile)) return; - - dir= sfile->dir; + BLI_parent_dir(sfile->dir); + + if (sfile->type!=FILE_MAIN && (sfile->dir[0]=='\0')) #ifdef WIN32 - if( (a = strlen(dir)) ) { /* remove all '/' at the end */ - while(dir[a-1] == '\\') { - a--; - dir[a] = 0; - if (a<=0) break; - } - } - if( (a = strlen(dir)) ) { /* then remove all until '/' */ - while(dir[a-1] != '\\') { - a--; - dir[a] = 0; - if (a<=0) break; - } - } - if( (a = strlen(dir)) ) { - if (dir[a-1] != '\\') strcat(dir,"\\"); - } - else if(sfile->type!=FILE_MAIN) { - get_default_root(dir); - } + get_default_root(sfile->dir); #else - if( (a = strlen(dir)) ) { /* remove all '/' at the end */ - while(dir[a-1] == '/') { - a--; - dir[a] = 0; - if (a<=0) break; - } - } - if( (a = strlen(dir)) ) { /* then remove until '/' */ - while(dir[a-1] != '/') { - a--; - dir[a] = 0; - if (a<=0) break; - } - } - if ( (a = strlen(dir)) ) { - if (dir[a-1] != '/') strcat(dir,"/"); - } - else if(sfile->type!=FILE_MAIN) strcpy(dir,"/"); + strcpy(sfile->dir,"/"); #endif /* to be sure */ @@ -1914,9 +1878,14 @@ void winqreadfilespace(ScrArea *sa, void *spacedata, BWinEvent *evt) { error("Path too long, cannot enter this directory"); } else { - strcat(sfile->dir, sfile->filelist[act].relname); - strcat(sfile->dir,"/"); - BLI_cleanup_dir(G.sce, sfile->dir); + if (strcmp(sfile->filelist[act].relname, "..")==0) { + /* avoids /../../ */ + BLI_parent_dir(sfile->dir); + } else { + strcat(sfile->dir, sfile->filelist[act].relname); + strcat(sfile->dir,"/"); + BLI_cleanup_dir(G.sce, sfile->dir); + } freefilelist(sfile); sfile->ofs= 0; do_draw= 1; |