summaryrefslogtreecommitdiff
path: root/src/drivers/Darwin
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/Darwin')
-rw-r--r--src/drivers/Darwin/Fl_Darwin_System_Driver.H1
-rw-r--r--src/drivers/Darwin/Fl_Darwin_System_Driver.cxx39
2 files changed, 40 insertions, 0 deletions
diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.H b/src/drivers/Darwin/Fl_Darwin_System_Driver.H
index ebb065dc3..77b646a29 100644
--- a/src/drivers/Darwin/Fl_Darwin_System_Driver.H
+++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.H
@@ -75,6 +75,7 @@ public:
virtual int need_menu_handle_part2() {return 1;}
virtual int open_uri(const char *uri, char *msg, int msglen);
virtual int need_test_shortcut_extra() {return 1;}
+ virtual int file_browser_load_filesystem(Fl_File_Browser *browser, char *filename, Fl_File_Icon *icon);
};
#endif // FL_DARWIN_SYSTEM_DRIVER_H
diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx
index c8c8c0c32..8ad45ad07 100644
--- a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx
+++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx
@@ -20,7 +20,9 @@
#include "../../config_lib.h"
#include "Fl_Darwin_System_Driver.H"
#include <FL/Fl.H>
+#include <FL/Fl_File_Browser.H>
#include <FL/filename.H>
+#include <FL/Fl_File_Icon.H>
#include <string.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
#include <xlocale.h>
@@ -29,6 +31,9 @@
#include <stdio.h>
#include <dlfcn.h>
#include <pwd.h>
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
extern int fl_mac_os_version; // the version number of the running Mac OS X
@@ -153,6 +158,40 @@ int Fl_Darwin_System_Driver::open_uri(const char *uri, char *msg, int msglen)
return run_program("/usr/bin/open", argv, msg, msglen) != 0;
}
+int Fl_Darwin_System_Driver::file_browser_load_filesystem(Fl_File_Browser *browser, char *filename, Fl_File_Icon *icon)
+{
+ // MacOS X and Darwin use getfsstat() system call...
+ int numfs; // Number of file systems
+ struct statfs *fs; // Buffer for file system info
+ int num_files = 0;
+
+ // We always have the root filesystem.
+ browser->add("/", icon);
+
+ // Get the mounted filesystems...
+ numfs = getfsstat(NULL, 0, MNT_NOWAIT);
+ if (numfs > 0) {
+ // We have file systems, get them...
+ fs = new struct statfs[numfs];
+ getfsstat(fs, sizeof(struct statfs) * numfs, MNT_NOWAIT);
+
+ // Add filesystems to the list...
+ for (int i = 0; i < numfs; i ++) {
+ // Ignore "/", "/dev", and "/.vol"...
+ if (fs[i].f_mntonname[1] && strcmp(fs[i].f_mntonname, "/dev") &&
+ strcmp(fs[i].f_mntonname, "/.vol")) {
+ snprintf(filename, sizeof(filename), "%s/", fs[i].f_mntonname);
+ browser->add(filename, icon);
+ }
+ num_files ++;
+ }
+
+ // Free the memory used for the file system info array...
+ delete[] fs;
+ }
+ return num_files;
+}
+
//
// End of "$Id$".