2.5 filebrowser
* 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.
This commit is contained in:
@@ -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--;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user