2.5 filebrowser
authorAndrea Weikert <elubie@gmx.net>
Sun, 12 Jul 2009 13:06:52 +0000 (13:06 +0000)
committerAndrea Weikert <elubie@gmx.net>
Sun, 12 Jul 2009 13:06:52 +0000 (13:06 +0000)
* bugfix: parent on linux didn't account for first slash
* added some BLI_cleanup_dir to prevent weird directory names
* revert to old directory if user types bogus text.

source/blender/blenlib/intern/util.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/filesel.c

index a236defc515a8b1184c447784cccbbe3177caaa9..78a4599b3b3e0aa14601fdd4260b0b5b5b1bd521 100644 (file)
@@ -502,7 +502,7 @@ int BLI_has_parent(char *path)
        BLI_add_slash(path);
 
        len = strlen(path)-1;
-       while (len) {
+       while (len>=0) {
                if ((path[len] == '\\') || (path[len] == '/'))
                        slashes++;
                len--;
index 8f1d2598c616caca59ed39c993223722cf5f6e2a..0d36bac750512aed34364f0efcf9b0e2c8435b07 100644 (file)
@@ -559,6 +559,7 @@ int file_parent_exec(bContext *C, wmOperator *unused)
        if(sfile->params) {
                if (BLI_has_parent(sfile->params->dir)) {
                        BLI_parent_dir(sfile->params->dir);
+                       BLI_cleanup_dir(G.sce, sfile->params->dir);
                        file_change_dir(sfile);
                        WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL);
                }
@@ -724,6 +725,7 @@ int file_directory_exec(bContext *C, wmOperator *unused)
                if (sfile->params->dir[0] == '\0')
                        get_default_root(sfile->params->dir);
 #endif
+               BLI_cleanup_dir(G.sce, sfile->params->dir);
                BLI_add_slash(sfile->params->dir);
                file_change_dir(sfile);
                WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL);
index c81dab454f811f2784f35c456f2f8191e55afe05..30712ea0b07f15208adb7c573f932280a7e077db 100644 (file)
@@ -301,16 +301,20 @@ FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar
 
 void file_change_dir(struct SpaceFile *sfile)
 {
-       if (sfile->params && BLI_exists(sfile->params->dir)) {
-               filelist_setdir(sfile->files, sfile->params->dir);
+       if (sfile->params) { 
+               if (BLI_exists(sfile->params->dir)) {
+                       filelist_setdir(sfile->files, sfile->params->dir);
 
-               if(folderlist_clear_next(sfile))
-                       folderlist_free(sfile->folders_next);
+                       if(folderlist_clear_next(sfile))
+                               folderlist_free(sfile->folders_next);
 
-               folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
+                       folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
 
-               filelist_free(sfile->files);
-               sfile->params->active_file = -1;
+                       filelist_free(sfile->files);
+                       sfile->params->active_file = -1;
+               } else {
+                       BLI_strncpy(sfile->params->dir, filelist_dir(sfile->files), FILE_MAX);
+               }
        }
 }