summaryrefslogtreecommitdiff
path: root/src/filename_list.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2002-05-02 11:11:01 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2002-05-02 11:11:01 +0000
commita237472c70abda43511b988a519f9672d37dc652 (patch)
tree0ecd052f262d37e47e2d300a0d53faed0f0b55eb /src/filename_list.cxx
parent540739e6d79a9a3fa77deef3c326993da9b3dc07 (diff)
Update fl_filename_list() to accept a sort function to use, and export
fl_alphasort, fl_casealphasort, fl_casenumericsort, and fl_numericsort. Still need to document this and provide hooks in the file chooser and browsers. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2174 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/filename_list.cxx')
-rw-r--r--src/filename_list.cxx40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/filename_list.cxx b/src/filename_list.cxx
index 8856594b7..c64ba9564 100644
--- a/src/filename_list.cxx
+++ b/src/filename_list.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: filename_list.cxx,v 1.10.2.11.2.2 2002/03/25 21:08:42 easysw Exp $"
+// "$Id: filename_list.cxx,v 1.10.2.11.2.3 2002/05/02 11:11:01 easysw Exp $"
//
// Filename list routines for the Fast Light Tool Kit (FLTK).
//
@@ -27,40 +27,50 @@
#include <config.h>
#include <FL/filename.H>
+#include "flstring.h"
+
extern "C" {
- int numericsort(dirent **, dirent **);
-#if HAVE_SCANDIR
-#else
- int alphasort(dirent **, dirent **);
- int scandir (const char *dir, dirent ***namelist,
- int (*select)(dirent *),
- int (*compar)(dirent **, dirent **));
+#ifndef HAVE_SCANDIR
+ int fl_scandir (const char *dir, dirent ***namelist,
+ int (*select)(dirent *),
+ int (*compar)(dirent **, dirent **));
+# define scandir fl_scandir
#endif
}
-int fl_filename_list(const char *d, dirent ***list) {
+int fl_alphasort(struct dirent **a, struct dirent **b) {
+ return strcmp((*a)->d_name, (*b)->d_name);
+}
+
+int fl_casealphasort(struct dirent **a, struct dirent **b) {
+ return strcasecmp((*a)->d_name, (*b)->d_name);
+}
+
+
+int fl_filename_list(const char *d, dirent ***list,
+ Fl_File_Sort_F *sort) {
#if defined(__hpux)
// HP-UX defines the comparison function like this:
- return scandir(d, list, 0, (int(*)(const dirent **, const dirent **))numericsort);
+ return scandir(d, list, 0, (int(*)(const dirent **, const dirent **))sort);
#elif defined(__osf__)
// OSF, DU 4.0x
- return scandir(d, list, 0, (int(*)(dirent **, dirent **))numericsort);
+ return scandir(d, list, 0, (int(*)(dirent **, dirent **))sort);
#elif defined(_AIX)
// AIX is almost standard...
- return scandir(d, list, 0, (int(*)(void*, void*))numericsort);
+ return scandir(d, list, 0, (int(*)(void*, void*))sort);
#elif HAVE_SCANDIR && !defined(__sgi)
// The vast majority of Unix systems want the sort function to have this
// prototype, most likely so that it can be passed to qsort without any
// changes:
- return scandir(d, list, 0, (int(*)(const void*,const void*))numericsort);
+ return scandir(d, list, 0, (int(*)(const void*,const void*))sort);
#else
// This version is when we define our own scandir (WIN32 and perhaps
// some Unix systems) and apparently on Irix:
- return scandir(d, list, 0, numericsort);
+ return scandir(d, list, 0, sort);
#endif
}
//
-// End of "$Id: filename_list.cxx,v 1.10.2.11.2.2 2002/03/25 21:08:42 easysw Exp $".
+// End of "$Id: filename_list.cxx,v 1.10.2.11.2.3 2002/05/02 11:11:01 easysw Exp $".
//