[Bf-blender-cvs] [114d1b2] master: Fix T44113: Some System Folders do not contain go back arrow.

Bastien Montagne noreply at git.blender.org
Wed Apr 8 21:59:55 CEST 2015


Commit: 114d1b23d298a9a5ddb6201046ec8b9e74661b7e
Author: Bastien Montagne
Date:   Wed Apr 8 21:54:52 2015 +0200
Branches: master
https://developer.blender.org/rB114d1b23d298a9a5ddb6201046ec8b9e74661b7e

Fix T44113: Some System Folders do not contain go back arrow.

On windows empty dirs are completely empty - no par or current entries
are listed either, in those cases artificially add those.

Furthermore, stat on UNC paths do not support current/parent 'shortcuts'
(i.e. things like '\\SERVER\foo\bar\..' do not work), so we have to hack
around that mess...

This should ensure us we always do have valid parrent entry...

===================================================================

M	source/blender/blenlib/intern/BLI_filelist.c
M	source/blender/editors/space_file/filelist.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 81813ce..b934b51 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -112,10 +112,40 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
 
 	if ((dir = opendir(dirname)) != NULL) {
 		const struct dirent *fname;
+		bool has_current = false, has_parent = false;
+
 		while ((fname = readdir(dir)) != NULL) {
 			struct dirlink * const dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
 			if (dlink != NULL) {
 				dlink->name = BLI_strdup(fname->d_name);
+				if (FILENAME_IS_PARENT(dlink->name)) {
+					has_parent = true;
+				}
+				else if (FILENAME_IS_CURRENT(dlink->name)) {
+					has_current = true;
+				}
+				BLI_addhead(&dirbase, dlink);
+				newnum++;
+			}
+		}
+
+		if (!has_parent) {
+			char pardir[FILE_MAXDIR];
+
+			BLI_strncpy(pardir, dirname, sizeof(pardir));
+			if (BLI_parent_dir(pardir) && (BLI_access(pardir, R_OK) == 0)) {
+				struct dirlink * const dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
+				if (dlink != NULL) {
+					dlink->name = BLI_strdup(FILENAME_PARENT);
+					BLI_addhead(&dirbase, dlink);
+					newnum++;
+				}
+			}
+		}
+		if (!has_current) {
+			struct dirlink * const dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
+			if (dlink != NULL) {
+				dlink->name = BLI_strdup(FILENAME_CURRENT);
 				BLI_addhead(&dirbase, dlink);
 				newnum++;
 			}
@@ -148,6 +178,10 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
 					if (BLI_stat(fullname, &file->s) != -1) {
 						file->type = file->s.st_mode;
 					}
+					else if (FILENAME_IS_CURRPAR(file->relname)) {
+						/* Hack around for UNC paths on windows - does not support stat on '\\SERVER\foo\..', sigh... */
+						file->type |= S_IFDIR;
+					}
 					file->flags = 0;
 					dir_ctx->nrfiles++;
 					file++;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index d5092ef..87e6183 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -900,7 +900,6 @@ static void filelist_setfiletypes(struct FileList *filelist)
 	file = filelist->filelist;
 
 	for (num = 0; num < filelist->numfiles; num++, file++) {
-		file->type = file->s.st_mode;  /* restore the mess below */
 #ifndef __APPLE__
 		/* Don't check extensions for directories, allow in OSX cause bundles have extensions*/
 		if (file->type & S_IFDIR) {




More information about the Bf-blender-cvs mailing list