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
This commit is contained in:
Michael R Sweet 2002-04-16 14:50:10 +00:00
parent 989b0cd372
commit dca53e213a
2 changed files with 40 additions and 6 deletions

View File

@ -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

View File

@ -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 $".
//