all: Use the openFile fopen wrapper from gfile.h
Use the openFile wrapper instead of calling fopen directly
in the libraries.
diff --git a/fofi/FoFiBase.cc b/fofi/FoFiBase.cc
index ad5d006..1337c0d 100644
--- a/fofi/FoFiBase.cc
+++ b/fofi/FoFiBase.cc
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <limits.h>
+#include "goo/gfile.h"
#include "goo/gmem.h"
#include "poppler/Error.h"
#include "FoFiBase.h"
@@ -51,7 +52,7 @@
char *buf;
int n;
- if (!(f = fopen(fileName, "rb"))) {
+ if (!(f = openFile(fileName, "rb"))) {
error(errIO, -1, "Cannot open '{0:s}'", fileName);
return nullptr;
}
diff --git a/fofi/FoFiIdentifier.cc b/fofi/FoFiIdentifier.cc
index e557e92..e6e4ba1 100644
--- a/fofi/FoFiIdentifier.cc
+++ b/fofi/FoFiIdentifier.cc
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <limits.h>
+#include "goo/gfile.h"
#include "FoFiIdentifier.h"
//------------------------------------------------------------------------
@@ -184,7 +185,7 @@
FileReader *FileReader::make(const char *fileName) {
FILE *fA;
- if (!(fA = fopen(fileName, "rb"))) {
+ if (!(fA = openFile(fileName, "rb"))) {
return nullptr;
}
return new FileReader(fA);
diff --git a/glib/poppler-attachment.cc b/glib/poppler-attachment.cc
index dd7064b..ff09edc 100644
--- a/glib/poppler-attachment.cc
+++ b/glib/poppler-attachment.cc
@@ -18,7 +18,8 @@
#include "config.h"
#include <errno.h>
-#include <glib/gstdio.h>
+
+#include <goo/gfile.h>
#include "poppler.h"
#include "poppler-private.h"
@@ -173,7 +174,7 @@
g_return_val_if_fail (POPPLER_IS_ATTACHMENT (attachment), FALSE);
- f = g_fopen (filename, "wb");
+ f = openFile (filename, "wb");
if (f == nullptr)
{
diff --git a/glib/poppler-media.cc b/glib/poppler-media.cc
index ab5f4c0..23689ae 100644
--- a/glib/poppler-media.cc
+++ b/glib/poppler-media.cc
@@ -20,7 +20,8 @@
#include "config.h"
#include <errno.h>
-#include <glib/gstdio.h>
+
+#include <goo/gfile.h>
#include "poppler-media.h"
#include "poppler-private.h"
@@ -214,7 +215,7 @@
g_return_val_if_fail (POPPLER_IS_MEDIA (poppler_media), FALSE);
g_return_val_if_fail (poppler_media->stream.isStream(), FALSE);
- f = g_fopen (filename, "wb");
+ f = openFile (filename, "wb");
if (f == nullptr)
{
diff --git a/poppler/FileSpec.cc b/poppler/FileSpec.cc
index 7c12da6..63452e6 100644
--- a/poppler/FileSpec.cc
+++ b/poppler/FileSpec.cc
@@ -28,6 +28,7 @@
#include <config.h>
#include "FileSpec.h"
+#include "goo/gfile.h"
EmbFile::EmbFile(Object &&efStream)
{
@@ -83,7 +84,7 @@
FILE *f;
bool ret;
- if (!(f = fopen(path, "wb"))) {
+ if (!(f = openFile(path, "wb"))) {
return false;
}
ret = save2(f);
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index c5a1000..14c7d47 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -46,6 +46,7 @@
#include <stddef.h>
#include <math.h>
#include <string.h>
+#include "goo/gfile.h"
#include "goo/gmem.h"
#include "Error.h"
#include "Object.h"
@@ -461,7 +462,7 @@
if (fileName[0] == '/') {
// full path
// check if open the file
- if ((fp = fopen(fileName,"r")) != nullptr) {
+ if ((fp = openFile(fileName,"r")) != nullptr) {
fclose(fp);
hp = cmsOpenProfileFromFile(fileName,"r");
}
@@ -471,7 +472,7 @@
GooString *path = new GooString(GLOBAL_COLOR_PROFILE_DIR);
path->append(fileName);
// check if open the file
- if ((fp = fopen(path->c_str(),"r")) != nullptr) {
+ if ((fp = openFile(path->c_str(),"r")) != nullptr) {
fclose(fp);
hp = cmsOpenProfileFromFile(path->c_str(),"r");
}
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 9a670ce..9ca0a42 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -1064,7 +1064,7 @@
fileName = nullptr;
if (dir) {
fileName = appendToPath(new GooString(dir), displayFontTab[i].t1FileName);
- if ((f = fopen(fileName->c_str(), "rb"))) {
+ if ((f = openFile(fileName->c_str(), "rb"))) {
fclose(f);
} else {
delete fileName;
@@ -1074,7 +1074,7 @@
for (j = 0; !fileName && displayFontDirs[j]; ++j) {
fileName = appendToPath(new GooString(displayFontDirs[j]),
displayFontTab[i].t1FileName);
- if ((f = fopen(fileName->c_str(), "rb"))) {
+ if ((f = openFile(fileName->c_str(), "rb"))) {
fclose(f);
} else {
delete fileName;
diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
index 83ece3c..86a28f4 100644
--- a/poppler/GlobalParamsWin.cc
+++ b/poppler/GlobalParamsWin.cc
@@ -216,7 +216,7 @@
static bool FileExists(const char *path)
{
- FILE * f = fopen(path, "rb");
+ FILE * f = openFile(path, "rb");
if (f) {
fclose(f);
return true;
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 93fa446..12f2919 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -897,7 +897,7 @@
Ref *refPage = getCatalog()->getPageRef(pageNo);
Object page = getXRef()->fetch(refPage->num, refPage->gen);
- if (!(f = fopen(name->c_str(), "wb"))) {
+ if (!(f = openFile(name->c_str(), "wb"))) {
error(errIO, -1, "Couldn't open file '{0:t}'", name);
return errOpenFile;
}
@@ -1030,7 +1030,7 @@
OutStream *outStr;
int res;
- if (!(f = fopen(name->c_str(), "wb"))) {
+ if (!(f = openFile(name->c_str(), "wb"))) {
error(errIO, -1, "Couldn't open file '{0:t}'", name);
return errOpenFile;
}
@@ -1062,7 +1062,7 @@
OutStream *outStr;
int res;
- if (!(f = fopen(name->c_str(), "wb"))) {
+ if (!(f = openFile(name->c_str(), "wb"))) {
error(errIO, -1, "Couldn't open file '{0:t}'", name);
return errOpenFile;
}
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 1eb75ae..6294f7e 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1141,7 +1141,7 @@
#endif
} else {
fileTypeA = psFile;
- if (!(f = fopen(fileName, "w"))) {
+ if (!(f = openFile(fileName, "w"))) {
error(errIO, -1, "Couldn't open PostScript file '{0:s}'", fileName);
ok = false;
return;
@@ -2309,7 +2309,7 @@
embFontList->append("\n");
// copy the font file
- if (!(fontFile = fopen(fileName->c_str(), "rb"))) {
+ if (!(fontFile = openFile(fileName->c_str(), "rb"))) {
error(errIO, -1, "Couldn't open external font file");
return;
}
diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 7a8f180..f1ec40d 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -59,6 +59,7 @@
#include <fcntl.h> // for O_BINARY
#include <io.h> // for setmode
#endif
+#include "goo/gfile.h"
#include "goo/gmem.h"
#include "goo/GooString.h"
#include "goo/GooList.h"
@@ -5637,7 +5638,7 @@
// keep DOS from munging the end-of-line characters
setmode(fileno(stdout), O_BINARY);
#endif
- } else if ((outputStream = fopen(fileName, append ? "ab" : "wb"))) {
+ } else if ((outputStream = openFile(fileName, append ? "ab" : "wb"))) {
needClose = true;
} else {
error(errIO, -1, "Couldn't open text file '{0:s}'", fileName);
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index 856fa08..7ce8b6f 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -36,6 +36,7 @@
#include <string.h>
#include <stdlib.h>
#include <limits.h>
+#include "goo/gfile.h"
#include "goo/gmem.h"
#include "SplashErrorCodes.h"
#include "SplashBitmap.h"
@@ -165,7 +166,7 @@
FILE *f;
SplashError e;
- if (!(f = fopen(fileName, "wb"))) {
+ if (!(f = openFile(fileName, "wb"))) {
return splashErrOpenFile;
}
@@ -262,7 +263,7 @@
if (!alpha) {
return splashErrModeMismatch;
}
- if (!(f = fopen(fileName, "wb"))) {
+ if (!(f = openFile(fileName, "wb"))) {
return splashErrOpenFile;
}
fprintf(f, "P5\n%d %d\n255\n", width, height);
@@ -338,7 +339,7 @@
FILE *f;
SplashError e;
- if (!(f = fopen(fileName, "wb"))) {
+ if (!(f = openFile(fileName, "wb"))) {
return splashErrOpenFile;
}