summaryrefslogtreecommitdiff
path: root/src/fl_utf8.cxx
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/fl_utf8.cxx
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/fl_utf8.cxx')
-rw-r--r--src/fl_utf8.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/fl_utf8.cxx b/src/fl_utf8.cxx
index b7d58eecd..afd5c6005 100644
--- a/src/fl_utf8.cxx
+++ b/src/fl_utf8.cxx
@@ -309,7 +309,7 @@ char *fl_getenv(const char* v) {
\param f the UTF-8 encoded filename
\param oflags other arguments are as in the standard open() function
\return a file descriptor upon successful completion, or -1 in case of error.
- \sa fl_fopen().
+ \sa fl_fopen(), fl_open_ext().
*/
int fl_open(const char* f, int oflags, ...)
{
@@ -321,6 +321,28 @@ int fl_open(const char* f, int oflags, ...)
return Fl::system_driver()->open(f, oflags, pmode);
}
+/** Cross-platform function to open files with a UTF-8 encoded name.
+ In comparison with fl_open(), this function allows to control whether
+ the file is opened in binary (a.k.a. untranslated) mode. This is especially
+ useful under the MSWindows 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 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 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);
+}
+
/** Cross-platform function to open files with a UTF-8 encoded name.