diff options
| author | Manolo Gouy <Manolo> | 2016-04-08 16:00:26 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-04-08 16:00:26 +0000 |
| commit | 1ba6928313c3fa25f3b6719a4dfdc9471e72d359 (patch) | |
| tree | d30cbb2942ee50ac2cde90e5c06acc348b766cef /src | |
| parent | 90682dbd481fca9b7b5b16086f3ac101081e8de5 (diff) | |
Rewrite filename_ext.cxx for the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11556 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 10 | ||||
| -rw-r--r-- | src/filename_ext.cxx | 21 |
3 files changed, 18 insertions, 14 deletions
diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H index 8203317ac..3e5f06d39 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H @@ -74,6 +74,7 @@ public: virtual int filename_absolute(char *to, int tolen, const char *from); virtual int filename_isdir(const char* n); virtual int filename_isdir_quick(const char* n); + virtual const char *filename_ext(const char *buf); }; #endif // FL_WINAPI_SYSTEM_DRIVER_H diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx index 693fd296d..246a26521 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx @@ -648,6 +648,16 @@ int Fl_WinAPI_System_Driver::filename_isdir_quick(const char* n) return filename_isdir(n); } +const char *Fl_WinAPI_System_Driver::filename_ext(const char *buf) { + const char *q = 0; + const char *p = buf; + for (p = buf; *p; p++) { + if (isdirsep(*p) ) q = 0; + else if (*p == '.') q = p; + } + return q ? q : p; +} + // // End of "$Id$". // diff --git a/src/filename_ext.cxx b/src/filename_ext.cxx index 367d57145..f07e6797f 100644 --- a/src/filename_ext.cxx +++ b/src/filename_ext.cxx @@ -16,18 +16,10 @@ // http://www.fltk.org/str.php // -// returns pointer to the last '.' or to the null if none: +#include <FL/Fl_System_Driver.H> +#include <FL/Fl.H> -#include <FL/filename.H> - -#ifdef WIN32 -#elif defined(__APPLE__) // PORTME: Fl_System_Driver - filename stuff -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: implement directory and filename handling for your platform if needed" -#else // X11 -#endif - -/** Gets the extensions of a filename. +/** Gets the extension of a filename. \code #include <FL/filename.H> [..] @@ -39,13 +31,14 @@ \return a pointer to the extension (including '.') if any or NULL otherwise */ const char *fl_filename_ext(const char *buf) { + return Fl::system_driver()->filename_ext(buf); +} + +const char *Fl_System_Driver::filename_ext(const char *buf) { const char *q = 0; const char *p = buf; for (p=buf; *p; p++) { if (*p == '/') q = 0; -#if defined(WIN32) || defined(__EMX__) && !defined(__CYGWIN__) - else if (*p == '\\') q = 0; -#endif else if (*p == '.') q = p; } return q ? q : p; |
