Revision: 22028
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22028
Author:   blendix
Date:     2009-07-29 23:35:03 +0200 (Wed, 29 Jul 2009)

Log Message:
-----------
2.5: File Browser on Unix

* Attempt to better filter file systems, it displayed all kinds
  of devices which are not interesting to the user. The trick
  used is now to use mounts starting with "/dev".
* Add / at the end to properly highlight directories in the list.
* Fix for non-linux unixes, this now falls back to showing / again.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/space_file/fsmenu.c

Modified: branches/blender2.5/blender/source/blender/editors/space_file/fsmenu.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/fsmenu.c      
2009-07-29 20:56:22 UTC (rev 22027)
+++ branches/blender2.5/blender/source/blender/editors/space_file/fsmenu.c      
2009-07-29 21:35:03 UTC (rev 22028)
@@ -307,8 +307,6 @@
                char dir[FILE_MAXDIR];
                char *home= BLI_gethome();
 
-               // fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0);
-
                if(home) {
                        BLI_snprintf(dir, FILE_MAXDIR, "%s/", home);
                        fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, dir, 
1, 0);
@@ -317,30 +315,42 @@
                }
 
                {
+                       int found= 0;
+#ifdef __linux__
                        /* loop over mount points */
                        struct mntent *mnt;
                        FILE *fp;
+                       int len;
+
                        fp = setmntent (MOUNTED, "r");
                        if (fp == NULL) {
                                fprintf(stderr, "could not get a list of 
mounted filesystemts\n");
                        }
                        else {
                                while ((mnt = getmntent (fp))) {
-                                       /* printf("%s %s %s %s %s %s\n", 
mnt->mnt_fsname, mnt->mnt_dir, mnt->mnt_type, mnt->mnt_opts, mnt->mnt_freq, 
mnt->mnt_passno); */
+                                       /* not sure if this is right, but seems 
to give the relevant mnts */
+                                       if(strncmp(mnt->mnt_fsname, "/dev", 4))
+                                               continue;
 
-                                       /* probably need to add more here */
-                                       if(     (strcmp (mnt->mnt_fsname, 
"none")==0) ||        /* /sys, /dev/pts */
-                                               (strcmp (mnt->mnt_type, 
"ramfs")==0)            /* /dev */
-                                       ) {
-                                               continue;
+                                       len= strlen(mnt->mnt_dir);
+                                       if(len && mnt->mnt_dir[len-1] != '/') {
+                                               BLI_snprintf(dir, FILE_MAXDIR, 
"%s/", mnt->mnt_dir);
+                                               fsmenu_insert_entry(fsmenu, 
FS_CATEGORY_SYSTEM, dir, 1, 0);
                                        }
+                                       else
+                                               fsmenu_insert_entry(fsmenu, 
FS_CATEGORY_SYSTEM, mnt->mnt_dir, 1, 0);
 
-                                       fsmenu_insert_entry(fsmenu, 
FS_CATEGORY_SYSTEM, mnt->mnt_dir, 1, 0);
+                                       found= 1;
                                }
                                if (endmntent (fp) == 0) {
                                        fprintf(stderr, "could not close the 
list of mounted filesystemts\n");
                                }
                        }
+#endif
+
+                       /* fallback */
+                       if(!found)
+                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, 
"/", 1, 0);
                }
        }
 #endif


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to