diff --git a/FL/Fl_System_Driver.H b/FL/Fl_System_Driver.H index 867db56f9..2b52c8afe 100644 --- a/FL/Fl_System_Driver.H +++ b/FL/Fl_System_Driver.H @@ -110,6 +110,8 @@ public: virtual int filename_isdir(const char* n); // the default implementation of filename_isdir_quick() is in src/filename_isdir.cxx and may be enough virtual int filename_isdir_quick(const char* n); + // the default implementation of filename_iext() is in src/filename_ext.cxx and may be enough + virtual const char *filename_ext(const char *buf); }; #endif // FL_SYSTEM_DRIVER_H 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 +#include -#include - -#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 [..] @@ -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;