summaryrefslogtreecommitdiff
path: root/src/drivers/WinAPI
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2017-10-12 14:42:12 +0000
committerManolo Gouy <Manolo>2017-10-12 14:42:12 +0000
commit789ed089c903922d0d66fcc2849dd24fbcaf2495 (patch)
tree8b36dfccefd881d7b85d81f2818933d447316096 /src/drivers/WinAPI
parenta526818778f1e378dbcfe300dc5ab42df023adfe (diff)
Add fl_open_ext() to control whether the file is opened in binary/text mode.
This new function allows to write Fl_SVG_Image::fl_gzopen() in a completely platform-independent way. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12489 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/WinAPI')
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_System_Driver.H1
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx7
2 files changed, 8 insertions, 0 deletions
diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
index 43e0f54e2..fdc686fed 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
@@ -50,6 +50,7 @@ public:
virtual char *getenv(const char* v);
virtual int putenv(char* v) {return _putenv(v);}
virtual int open(const char* f, int oflags, int pmode);
+ virtual int open_ext(const char* f, int translation, int oflags, int pmode);
virtual FILE *fopen(const char* f, const char *mode);
virtual int system(const char* cmd);
virtual int execvp(const char *file, char *const *argv);
diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
index efbe65d01..aa1ff7e50 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
@@ -42,6 +42,7 @@ typedef RPC_STATUS (WINAPI* uuid_func)(UUID __RPC_FAR *Uuid);
#include <time.h>
#include <direct.h>
#include <io.h>
+#include <fcntl.h>
// Apparently Borland C++ defines DIRECTORY in <direct.h>, which
// interfers with the Fl_File_Icon enumeration of the same name.
# ifdef DIRECTORY
@@ -136,6 +137,12 @@ int Fl_WinAPI_System_Driver::open(const char* f, int oflags, int pmode) {
else return _wopen(wbuf, oflags, pmode);
}
+int Fl_WinAPI_System_Driver::open_ext(const char* f, int translation, int oflags, int pmode) {
+ if (oflags == 0) oflags = _O_RDONLY;
+ oflags |= (translation ? _O_TEXT : _O_BINARY);
+ return this->open(f, oflags, pmode);
+}
+
FILE *Fl_WinAPI_System_Driver::fopen(const char* f, const char *mode) {
size_t l = strlen(f);
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length