Rename fl_open_ext() parameter 'translation' to 'binary'.
The default (0) is 'text' mode, non-zero is 'binary' mode on platforms that distinguish text and binary mode. Currently Windows is the only supported platform that needs this. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12500 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
1ff9144801
commit
f9cfe1378d
2
CHANGES
2
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.
|
||||
|
@ -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;}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user