[Bf-blender-cvs] [f74fa98e537] master: Linux: list GVFS mount points

Roel Koster noreply at git.blender.org
Sun Nov 18 22:53:29 CET 2018


Commit: f74fa98e537d820302c3f787ec68a91a3dd254b9
Author: Roel Koster
Date:   Mon Nov 19 08:34:04 2018 +1100
Branches: master
https://developer.blender.org/rBf74fa98e537d820302c3f787ec68a91a3dd254b9

Linux: list GVFS mount points

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

M	source/blender/editors/space_file/fsmenu.c

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

diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 06a78c92f09..359cce45baa 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -59,6 +59,7 @@
 
 #ifdef __linux__
 #include <mntent.h>
+#include "BLI_fileops_types.h"
 #endif
 
 #include "fsmenu.h"  /* include ourselves */
@@ -630,6 +631,33 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
 					fprintf(stderr, "could not close the list of mounted filesystems\n");
 				}
 			}
+			/* Check gvfs shares. */
+			const char * const xdg_runtime_dir = BLI_getenv("XDG_RUNTIME_DIR");
+			if (xdg_runtime_dir != NULL) {
+				struct direntry *dir;
+				char name[FILE_MAX];
+				BLI_join_dirfile(name, sizeof(name), xdg_runtime_dir, "gvfs/");
+				const uint dir_len = BLI_filelist_dir_contents(name, &dir);
+				for (uint i = 0; i < dir_len; i++) {
+					if ((dir[i].type & S_IFDIR)) {
+						const char *dirname = dir[i].relname;
+						if (dirname[0] != '.') {
+							/* Dir names contain a lot of unwanted text.
+							 * Assuming every entry ends with the share name */
+							const char *label = strstr(dirname, "share=");
+							if (label != NULL) {
+								/* Move pointer so "share=" is trimmed off or use full dirname as label. */
+								const char *label_test = label + 6;
+								label = *label_test ? label_test : dirname;
+							}
+							BLI_snprintf(line, sizeof(line), "%s%s/", name, dirname);
+							fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, label, FS_INSERT_SORTED);
+							found = 1;
+						}
+					}
+				}
+				BLI_filelist_free(dir, dir_len);
+			}
 #endif
 
 			/* fallback */



More information about the Bf-blender-cvs mailing list