summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--FL/Fl_System_Driver.H7
-rw-r--r--FL/fl_utf8.h2
-rw-r--r--src/Fl_SVG_Image.cxx2
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_System_Driver.H2
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx4
-rw-r--r--src/fl_images_core.cxx2
-rw-r--r--src/fl_utf8.cxx8
8 files changed, 17 insertions, 12 deletions
diff --git a/CHANGES b/CHANGES
index 24f53ad4b..9f27401e4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -18,7 +18,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2017
New Features and Extensions
- (add new items here)
- - New function: int fl_open_ext(const char* fname, int translation, int oflags, ...)
+ - New function: int fl_open_ext(const char* fname, int binary, int oflags, ...)
to control the opening of files in binary/text mode in a cross-platform way.
- New Fl_SVG_Image class: gives support of scalable vector graphics images
to FLTK using the nanosvg software.
diff --git a/FL/Fl_System_Driver.H b/FL/Fl_System_Driver.H
index dfdd4c3e3..e49306a96 100644
--- a/FL/Fl_System_Driver.H
+++ b/FL/Fl_System_Driver.H
@@ -87,7 +87,12 @@ public:
virtual char *getenv(const char* v) {return NULL;}
virtual int putenv(char* v) {return -1;}
virtual int open(const char* f, int oflags, int pmode) {return -1;}
- virtual int open_ext(const char* f, int translation, int oflags, int pmode) {return this->open(f, oflags, pmode);}
+
+ // Note: the default implementation ignores the 'binary' argument.
+ // Some platforms (notably Windows) may use this argument.
+ virtual int open_ext(const char* f, int binary, int oflags, int pmode) {
+ return this->open(f, oflags, pmode);
+ }
virtual FILE *fopen(const char* f, const char *mode);
virtual int system(const char* cmd) {return -1;}
virtual int execvp(const char *file, char *const *argv) {return -1;}
diff --git a/FL/fl_utf8.h b/FL/fl_utf8.h
index 2b1623138..68ebf3f05 100644
--- a/FL/fl_utf8.h
+++ b/FL/fl_utf8.h
@@ -177,7 +177,7 @@ FL_EXPORT int fl_execvp(const char *file, char *const *argv);
/* OD: Portable UTF-8 aware open wrapper */
FL_EXPORT int fl_open(const char* f, int o, ...);
-FL_EXPORT int fl_open_ext(const char* fname, int translation, int oflags, ...);
+FL_EXPORT int fl_open_ext(const char* fname, int binary, int oflags, ...);
/* OD: Portable UTF-8 aware unlink wrapper */
FL_EXPORT int fl_unlink(const char *fname);
diff --git a/src/Fl_SVG_Image.cxx b/src/Fl_SVG_Image.cxx
index 45b0f74c4..d631e6a76 100644
--- a/src/Fl_SVG_Image.cxx
+++ b/src/Fl_SVG_Image.cxx
@@ -82,7 +82,7 @@ static char *svg_inflate(const char *fname) {
struct stat b;
fl_stat(fname, &b);
long size = b.st_size;
- int fd = fl_open_ext(fname, 0, 0);
+ int fd = fl_open_ext(fname, 1, 0);
if (fd < 0) return NULL;
gzFile gzf = gzdopen(fd, "r");
if (!gzf) return NULL;
diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
index fdc686fed..6b3a1e85e 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
@@ -50,7 +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 int open_ext(const char* f, int binary, 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 aa1ff7e50..806a76b22 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
@@ -137,9 +137,9 @@ 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) {
+int Fl_WinAPI_System_Driver::open_ext(const char* f, int binary, int oflags, int pmode) {
if (oflags == 0) oflags = _O_RDONLY;
- oflags |= (translation ? _O_TEXT : _O_BINARY);
+ oflags |= (binary ? _O_BINARY : _O_TEXT);
return this->open(f, oflags, pmode);
}
diff --git a/src/fl_images_core.cxx b/src/fl_images_core.cxx
index 0aa5bc49d..06930d17c 100644
--- a/src/fl_images_core.cxx
+++ b/src/fl_images_core.cxx
@@ -95,7 +95,7 @@ fl_check_images(const char *name, // I - Filename
#ifdef FLTK_USE_NANOSVG
# if defined(HAVE_LIBZ)
if (header[0] == 0x1f && header[1] == 0x8b) { // denotes gzip'ed data
- int fd = fl_open_ext(name, 0, 0);
+ int fd = fl_open_ext(name, 1, 0);
if (fd < 0) return NULL;
gzFile gzf = gzdopen(fd, "r");
if (gzf) {
diff --git a/src/fl_utf8.cxx b/src/fl_utf8.cxx
index de6a7ee54..60d7614d6 100644
--- a/src/fl_utf8.cxx
+++ b/src/fl_utf8.cxx
@@ -339,20 +339,20 @@ int fl_open(const char* f, int oflags, ...)
useful on the Windows platform where files are by default opened in
text (translated) mode.
\param fname the UTF-8 encoded filename
- \param translation if zero, the file is to be accessed in untranslated (a.k.a. binary)
- mode.
+ \param binary if non-zero, the file is to be accessed in binary (a.k.a.
+ untranslated) mode.
\param oflags,... these arguments are as in the standard open() function.
Setting \p oflags to zero opens the file for reading.
\return a file descriptor upon successful completion, or -1 in case of error.
*/
-int fl_open_ext(const char* fname, int translation, int oflags, ...)
+int fl_open_ext(const char* fname, int binary, int oflags, ...)
{
int pmode;
va_list ap;
va_start(ap, oflags);
pmode = va_arg (ap, int);
va_end(ap);
- return Fl::system_driver()->open_ext(fname, translation, oflags, pmode);
+ return Fl::system_driver()->open_ext(fname, binary, oflags, pmode);
}