diff options
| author | Greg Ercolano <erco@seriss.com> | 2020-07-14 11:34:18 -0700 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2020-07-14 11:34:18 -0700 |
| commit | 54425030774eb04b29c749ffa85d224c8bbfcc34 (patch) | |
| tree | f6e8b0c9fd46f5bcf160de82d613e7799288e277 /src/drivers/Darwin | |
| parent | 58296c373a79ac404e86f8a4b20a5309db2f00de (diff) | |
| parent | da76085fe71d2271847f95f5aa0694a9373fbba0 (diff) | |
Merge branch 'issue-99a': add OS error messages to Fl_File_Chooser
Pulling in Greg & Albrecht's work on PR #99 and PR #103.
This includes supporting operating system error messages
in the user's local language, which took some extra effort.
Diffstat (limited to 'src/drivers/Darwin')
| -rw-r--r-- | src/drivers/Darwin/Fl_Darwin_System_Driver.H | 4 | ||||
| -rw-r--r-- | src/drivers/Darwin/Fl_Darwin_System_Driver.cxx | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.H b/src/drivers/Darwin/Fl_Darwin_System_Driver.H index ee7ab30ea..548277901 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.H +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.H @@ -52,7 +52,9 @@ public: // these 2 are in Fl_get_key_mac.cxx virtual int event_key(int k); virtual int get_key(int k); - virtual int filename_list(const char *d, dirent ***list, int (*sort)(struct dirent **, struct dirent **) ); + virtual int filename_list(const char *d, dirent ***list, + int (*sort)(struct dirent **, struct dirent **), + char *errmsg=NULL, int errmsg_sz=0); virtual int open_uri(const char *uri, char *msg, int msglen); virtual int need_test_shortcut_extra() {return 1;} virtual int file_browser_load_filesystem(Fl_File_Browser *browser, char *filename, int lname, Fl_File_Icon *icon); diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx index 51a416b87..0c1a9de9e 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx @@ -15,6 +15,7 @@ // #include "Fl_Darwin_System_Driver.H" +#include <src/flstring.h> #include <FL/platform.H> #include <FL/Fl.H> #include <FL/Fl_File_Browser.H> @@ -139,7 +140,9 @@ void *Fl_Darwin_System_Driver::get_carbon_function(const char *function_name) { return (carbon ? dlsym(carbon, function_name) : NULL); } -int Fl_Darwin_System_Driver::filename_list(const char *d, dirent ***list, int (*sort)(struct dirent **, struct dirent **) ) { +int Fl_Darwin_System_Driver::filename_list(const char *d, dirent ***list, + int (*sort)(struct dirent **, struct dirent **), + char *errmsg, int errmsg_sz) { int dirlen; char *dirloc; // Assume that locale encoding is no less dense than UTF-8 @@ -150,6 +153,10 @@ int Fl_Darwin_System_Driver::filename_list(const char *d, dirent ***list, int (* # else int n = scandir(dirloc, list, 0, (int(*)(const void*,const void*))sort); # endif + if (n==-1) { + if (errmsg) fl_snprintf(errmsg, errmsg_sz, "%s", strerror(errno)); + return -1; + } // convert every filename to UTF-8, and append a '/' to all // filenames that are directories int i; |
