summaryrefslogtreecommitdiff
path: root/FL
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-04-07 15:10:30 +0000
committerManolo Gouy <Manolo>2016-04-07 15:10:30 +0000
commit23a60edb44d264887a398eef1b6346f8f24737e2 (patch)
treeae6920a8b002dd26240f560d61df84888ba3b4a5 /FL
parent406fcaf3053b2d8d9c8ea677c59667a7ec43a556 (diff)
Rewrite filename_list.cxx under the driver model.
One more platform-dependent type is necessary: struct dirent Create a new header file, FL/platform_types.h, to define all types whose definition is platform-dependent. This file is for C because it is included by scandir_XXX.c git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11550 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
-rw-r--r--FL/Fl_System_Driver.H50
-rw-r--r--FL/dirent.h25
-rw-r--r--FL/filename.H45
-rw-r--r--FL/platform_types.h83
4 files changed, 89 insertions, 114 deletions
diff --git a/FL/Fl_System_Driver.H b/FL/Fl_System_Driver.H
index 9d5813e67..7984a6050 100644
--- a/FL/Fl_System_Driver.H
+++ b/FL/Fl_System_Driver.H
@@ -25,56 +25,10 @@
#define FL_SYSTEM_DRIVER_H
#include <FL/Fl_Export.H>
+#include <FL/platform_types.h>
#include <stdio.h>
#include <stdarg.h>
-// platform-dependent types are declared here
-#ifdef __APPLE__
-typedef struct CGContext* Fl_Offscreen;
-typedef struct CGImage* Fl_Bitmask;
-typedef struct flCocoaRegion* Fl_Region;
-typedef int FL_SOCKET;
-#include <sys/stat.h>
-
-#elif defined(WIN32)
-typedef struct HBITMAP__ *HBITMAP;
-typedef HBITMAP Fl_Offscreen;
-typedef HBITMAP Fl_Bitmask;
-typedef struct HRGN__ *Fl_Region;
-# if defined(_WIN64)
-typedef unsigned __int64 FL_SOCKET;
-# else
-typedef int FL_SOCKET;
-# endif
-#include <sys/stat.h>
-
-#elif defined(FL_PORTING)
-# pragma message "FL_PORTING: define OS-dependent types"
-typedef void* Fl_Offscreen;
-typedef void* Fl_Bitmask;
-typedef void *Fl_Region;
-typedef int FL_SOCKET;
-# pragma message "FL_PORTING: define struct stat and implement stat() for the platform"
-struct stat { // the FLTK source code uses part of the stat() API
- unsigned st_mode;
- off_t st_size;
-};
-#define S_IFMT 0170000 /* type of file */
-#define S_IFIFO 0010000 /* named pipe (fifo) */
-#define S_IFCHR 0020000 /* character special */
-#define S_IFDIR 0040000 /* directory */
-#define S_IFBLK 0060000 /* block special */
-#define S_IFREG 0100000 /* regular */
-#define S_IFLNK 0120000 /* symbolic link */
-
-#else
-typedef unsigned long Fl_Offscreen;
-typedef unsigned long Fl_Bitmask;
-typedef struct _XRegion *Fl_Region;
-typedef int FL_SOCKET;
-#include <sys/stat.h>
-
-#endif // __APPLE__
/**
\brief A base class for platform-specific system operations.
@@ -142,6 +96,8 @@ public:
// implement functions telling whether a key is pressed
virtual int event_key(int k) {return 0;}
virtual int get_key(int k) {return 0;}
+ // implement scandir-like function
+ virtual int filename_list(const char *d, dirent ***list, int (*sort)(struct dirent **, struct dirent **) ) {return -1;}
};
#endif // FL_SYSTEM_DRIVER_H
diff --git a/FL/dirent.h b/FL/dirent.h
deleted file mode 100644
index f99f44ea5..000000000
--- a/FL/dirent.h
+++ /dev/null
@@ -1,25 +0,0 @@
-//
-// "$Id$"
-//
-// Directory header file for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2011 by Bill Spitzak and others.
-//
-// This library is free software. Distribution and use rights are outlined in
-// the file "COPYING" which should have been included with this file. If this
-// file is missing or damaged, see the license at:
-//
-// http://www.fltk.org/COPYING.php
-//
-// Please report all bugs and problems on the following page:
-//
-// http://www.fltk.org/str.php
-//
-
-
-// this file is for back-compatibility only
-#include "filename.H"
-
-//
-// End of "$Id$".
-//
diff --git a/FL/filename.H b/FL/filename.H
index acc8056ed..745a14591 100644
--- a/FL/filename.H
+++ b/FL/filename.H
@@ -19,17 +19,11 @@
File names and URI utility functions.
*/
-/* Xcode on OS X includes files by recursing down into directories.
- * This code catches the cycle and directly includes the required file.
- */
-#ifdef fl_dirent_h_cyclic_include
-# include "/usr/include/dirent.h"
-#endif
-
#ifndef FL_FILENAME_H
# define FL_FILENAME_H
-# include "Fl_Export.H"
+#include "Fl_Export.H"
+#include <FL/platform_types.h>
/** \addtogroup filenames File names and URI utility functions
File names and URI functions defined in <FL/filename.H>
@@ -72,39 +66,6 @@ FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from, const
inline int fl_filename_relative(char *to, const char *from) { return fl_filename_relative(to, FL_PATH_MAX, from); }
# endif /* __cplusplus */
-
-# if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
-
-struct dirent {char d_name[1];};
-
-# elif defined(__WATCOMC__)
-# include <sys/types.h>
-# include <direct.h>
-
-# elif defined(FL_PORTING)
-# pragma message "FL_PORTING: insert the equivalent to dirent.h on your system"
-# include <dirent.h>
-# else
-/*
- * WARNING: on some systems (very few nowadays?) <dirent.h> may not exist.
- * The correct information is in one of these files:
- *
- * #include <sys/ndir.h>
- * #include <sys/dir.h>
- * #include <ndir.h>
- *
- * plus you must do the following #define:
- *
- * #define dirent direct
- *
- * It would be best to create a <dirent.h> file that does this...
- */
-# include <sys/types.h>
-# define fl_dirent_h_cyclic_include
-# include <dirent.h>
-# undef fl_dirent_h_cyclic_include
-# endif
-
# if defined (__cplusplus)
extern "C" {
# endif /* __cplusplus */
@@ -116,7 +77,7 @@ FL_EXPORT int fl_casenumericsort(struct dirent **, struct dirent **);
FL_EXPORT int fl_numericsort(struct dirent **, struct dirent **);
# endif
- typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **); /**< File sorting function. \see fl_filename_list() */
+typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **); /**< File sorting function. \see fl_filename_list() */
# if defined(__cplusplus)
}
diff --git a/FL/platform_types.h b/FL/platform_types.h
new file mode 100644
index 000000000..bd3d9e7f1
--- /dev/null
+++ b/FL/platform_types.h
@@ -0,0 +1,83 @@
+/*
+ * "$Id: platform_types.h 11467 2016-03-29 19:41:14Z manolo $"
+ *
+ * Copyright 2016 by Bill Spitzak and others.
+ *
+ * This library is free software. Distribution and use rights are outlined in
+ * the file "COPYING" which should have been included with this file. If this
+ * file is missing or damaged, see the license at:
+ *
+ * http://www.fltk.org/COPYING.php
+ *
+ * Please report all bugs and problems on the following page:
+ *
+ * http://www.fltk.org/str.php
+ */
+
+#ifndef PLATFORM_TYPES_H
+#define PLATFORM_TYPES_H
+
+/* Platform-dependent types are defined here
+ These types must be defined by any platform:
+ Fl_Offscreen, Fl_Bitmask, Fl_Region, FL_SOCKET, struct dirent, struct stat
+ */
+
+#ifdef __APPLE__
+typedef struct CGContext* Fl_Offscreen;
+typedef struct CGImage* Fl_Bitmask;
+typedef struct flCocoaRegion* Fl_Region;
+typedef int FL_SOCKET;
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+#elif defined(WIN32)
+typedef struct HBITMAP__ *HBITMAP;
+typedef HBITMAP Fl_Offscreen;
+typedef HBITMAP Fl_Bitmask;
+typedef struct HRGN__ *Fl_Region;
+# if defined(_WIN64)
+typedef unsigned __int64 FL_SOCKET;
+# else
+typedef int FL_SOCKET;
+# endif
+#include <sys/stat.h>
+struct dirent {char d_name[1];};
+
+#elif defined(FL_PORTING)
+# pragma message "FL_PORTING: define OS-dependent types"
+typedef void* Fl_Offscreen;
+typedef void* Fl_Bitmask;
+typedef void *Fl_Region;
+typedef int FL_SOCKET;
+# pragma message "FL_PORTING: define struct dirent and implement scandir() for the platform"
+struct dirent {char d_name[1];};
+# pragma message "FL_PORTING: define struct stat and implement stat() for the platform"
+struct stat { /* the FLTK source code uses part of the stat() API */
+ unsigned st_mode;
+ off_t st_size;
+};
+#define S_IFMT 0170000 /* type of file */
+#define S_IFIFO 0010000 /* named pipe (fifo) */
+#define S_IFCHR 0020000 /* character special */
+#define S_IFDIR 0040000 /* directory */
+#define S_IFBLK 0060000 /* block special */
+#define S_IFREG 0100000 /* regular */
+#define S_IFLNK 0120000 /* symbolic link */
+
+#else
+typedef unsigned long Fl_Offscreen;
+typedef unsigned long Fl_Bitmask;
+typedef struct _XRegion *Fl_Region;
+typedef int FL_SOCKET;
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+#endif // __APPLE__
+
+#endif /* PLATFORM_TYPES_H */
+
+/*
+ * End of "$Id: platform_types.h 11467 2016-03-29 19:41:14Z manolo $".
+ */