summaryrefslogtreecommitdiff
path: root/src/Fl_File_Browser.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2005-08-17 21:56:22 +0000
committerMatthias Melcher <fltk@matthiasm.com>2005-08-17 21:56:22 +0000
commiteca40efb6e42b352ca77d1d290b4149037b70efd (patch)
tree605f7653442f1a0ae8cd95af7e345708419d309a /src/Fl_File_Browser.cxx
parent760bca71abe9e35e393c05404672d362b463128e (diff)
This change is controversial. It changes the behavior of fl_filename_list
slightly by adding a forward slash after every directory name on every supported OS. Included in this patch is a change in the code that lists mounted volumes on OS X Mac. Apple users, please check. Open FLUID, open the file dialog and clear the current path. You shoudl see a list of mounted volumes. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4525 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_File_Browser.cxx')
-rw-r--r--src/Fl_File_Browser.cxx48
1 files changed, 14 insertions, 34 deletions
diff --git a/src/Fl_File_Browser.cxx b/src/Fl_File_Browser.cxx
index 94e69e8b0..22ae7eada 100644
--- a/src/Fl_File_Browser.cxx
+++ b/src/Fl_File_Browser.cxx
@@ -67,6 +67,7 @@
// CodeWarrior (__MWERKS__) gets its include paths confused, so we
// temporarily disable this...
#if defined(__APPLE__) && !defined(__MWERKS__)
+# include <Carbon/Carbon.h>
# include <sys/param.h>
# include <sys/ucred.h>
# include <sys/mount.h>
@@ -495,30 +496,20 @@ Fl_File_Browser::load(const char *directory,// I - Directory to load
num_files ++;
}
#elif defined(__APPLE__) && !defined(__MWERKS__)
- // 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 ++;
+ // All mounted volumes are in a directory called '/Volumes/'
+ // This seems to be the case on international installations, too.
+ add("/", icon);
+ dirent **dir;
+ int n = fl_filename_list("/Volumes/", &dir, 0);
+ if (n>=0) {
+ int i;
+ for (i=0; i<n; i++) {
+ if (dir[i]->d_name[0]=='.') continue;
+ sprintf(filename, "/Volumes/%s", dir[i]->d_name);
+ add(filename, icon);
+ free(dir[i]);
}
-
- // Free the memory used for the file system info array...
- delete[] fs;
+ free(dir);
}
#else
//
@@ -596,18 +587,7 @@ Fl_File_Browser::load(const char *directory,// I - Directory to load
if ((icon && icon->type() == Fl_File_Icon::DIRECTORY) ||
fl_filename_isdir(filename)) {
num_dirs ++;
-
-#if defined(WIN32) && !defined(__CYGWIN__)
- // WIN32 already has the trailing slash... :)
insert(num_dirs, files[i]->d_name, icon);
-#else
- // Add a trailing slash to directory names...
- char name[1024]; // Temporary directory name
-
- snprintf(name, sizeof(name), "%s/", files[i]->d_name);
-
- insert(num_dirs, name, icon);
-#endif // WIN32 && !__CYGWIN__
} else if (filetype_ == FILES &&
fl_filename_match(files[i]->d_name, pattern_)) {
add(files[i]->d_name, icon);