summaryrefslogtreecommitdiff
path: root/goo
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2019-01-03 21:11:49 +0100
committerChristian Persch <chpe@src.gnome.org>2019-01-03 21:11:49 +0100
commit4a3eef323d72b06780c318f58917f884eecc812e (patch)
tree1ae062e2e602f2f4c077ac895752c5c7f11b6473 /goo
parente1e4457a235f6107c09d32994fc628efa9e7bd0e (diff)
gfile: Add wrapper for open(3p) and use it instead of directly calling open
This is in preparation to making the wrapper enforce the O_CLOEXEC flag.
Diffstat (limited to 'goo')
-rw-r--r--goo/gfile.cc6
-rw-r--r--goo/gfile.h3
2 files changed, 8 insertions, 1 deletions
diff --git a/goo/gfile.cc b/goo/gfile.cc
index 819559c0..c2973416 100644
--- a/goo/gfile.cc
+++ b/goo/gfile.cc
@@ -270,6 +270,10 @@ GooString *appendToPath(GooString *path, const char *fileName) {
#endif
}
+int openFileDescriptor(const char *path, int flags) {
+ return open(path, flags);
+}
+
FILE *openFile(const char *path, const char *mode) {
#ifdef _WIN32
OSVERSIONINFO version;
@@ -485,7 +489,7 @@ GooFile* GooFile::open(const GooString *fileName) {
#ifdef VMS
int fd = ::open(fileName->c_str(), Q_RDONLY, "ctx=stm");
#else
- int fd = ::open(fileName->c_str(), O_RDONLY);
+ int fd = openFileDescriptor(fileName->c_str(), O_RDONLY);
#endif
return fd < 0 ? nullptr : new GooFile(fd);
diff --git a/goo/gfile.h b/goo/gfile.h
index bd58e6c0..b0b942fd 100644
--- a/goo/gfile.h
+++ b/goo/gfile.h
@@ -88,6 +88,9 @@ typedef long long Goffset;
// string, denoting the current directory). Returns <path>.
extern GooString *appendToPath(GooString *path, const char *fileName);
+// Open a file descriptor
+extern int openFileDescriptor(const char *path, int flags);
+
// Open a file. On Windows, this converts the path from UTF-8 to
// UCS-2 and calls _wfopen (if available). On other OSes, this simply
// calls fopen.