diff options
| author | Manolo Gouy <Manolo> | 2016-04-10 06:33:19 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-04-10 06:33:19 +0000 |
| commit | 927774af85b115b2affa35252a46cc6f3235fe97 (patch) | |
| tree | fe59b0041ae84c9a8b52b67dfb63e732f8c57415 /src/drivers/Darwin/Fl_Darwin_System_Driver.cxx | |
| parent | 9ca66c6f3d3c94192e105012fc8226109530143a (diff) | |
Rewrite Fl_File_Browser.cxx under the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11570 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Darwin/Fl_Darwin_System_Driver.cxx')
| -rw-r--r-- | src/drivers/Darwin/Fl_Darwin_System_Driver.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
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$". |
