diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2002-04-16 14:50:10 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2002-04-16 14:50:10 +0000 |
| commit | dca53e213a96cb6291f8f7c56cb35d6259adef43 (patch) | |
| tree | 98551d62880680b0ab4cb96e257a26969afda8f1 | |
| parent | 989b0cd372cf00775950c74d5455942671537fe4 (diff) | |
Implement file system list for file chooser on OS X.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2092 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | CHANGES | 4 | ||||
| -rw-r--r-- | src/Fl_File_Browser.cxx | 42 |
2 files changed, 40 insertions, 6 deletions
@@ -1,5 +1,7 @@ -CHANGES IN FLTK 1.1.0 +CHANGES IN FLTK 1.1.0rc1 + - The filesystem list in the file chooser now works under + MacOS X and Darwin. - The fl_msg structure now contains all data passed to the WndProc function under WIN32. - Fixed some window focus/positioning problems under diff --git a/src/Fl_File_Browser.cxx b/src/Fl_File_Browser.cxx index 8d17bb345..4962ea62b 100644 --- a/src/Fl_File_Browser.cxx +++ b/src/Fl_File_Browser.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_File_Browser.cxx,v 1.1.2.9 2002/04/14 12:51:55 easysw Exp $" +// "$Id: Fl_File_Browser.cxx,v 1.1.2.10 2002/04/16 14:50:10 easysw Exp $" // // Fl_File_Browser routines. // @@ -49,13 +49,19 @@ #elif defined(WIN32) # include <windows.h> # include <direct.h> -#endif /* __CYGWIN__ */ +#endif // __CYGWIN__ -#if defined(__EMX__) +#ifdef __EMX__ # define INCL_DOS # define INCL_DOSMISC # include <os2.h> -#endif /* __EMX__ */ +#endif // __EMX__ + +#ifdef __APPLE__ +# include <sys/param.h> +# include <sys/ucred.h> +# include <sys/mount.h> +#endif // __APPLE__ // @@ -465,6 +471,32 @@ Fl_File_Browser::load(const char *directory)// I - Directory to load num_files ++; } +#elif defined(__APPLE__) + // MacOS X and Darwin use getfsstat() system call... + int numfs; // Number of file systems + struct statfs *fs; // Buffer for file system info + + + 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 (i = 0; i < numfs; i ++) { + if (fs[i].f_mntonname[1]) { + snprintf(filename, sizeof(filename), "%s/", fs[i].f_mntonname); + add(filename, icon); + } else { + add("/", icon); + } + num_files ++; + } + + // Free the memory used for the file system info array... + delete[] fs; + } #else // // UNIX code uses /etc/fstab or similar... @@ -583,5 +615,5 @@ Fl_File_Browser::filter(const char *pattern) // I - Pattern string // -// End of "$Id: Fl_File_Browser.cxx,v 1.1.2.9 2002/04/14 12:51:55 easysw Exp $". +// End of "$Id: Fl_File_Browser.cxx,v 1.1.2.10 2002/04/16 14:50:10 easysw Exp $". // |
