File indexing completed on 2025-12-11 10:26:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef GFILE_H
0036 #define GFILE_H
0037
0038 #include "poppler-config.h"
0039 #include "poppler_private_export.h"
0040 #include <cstdio>
0041 #include <cstdlib>
0042 #include <cstddef>
0043 #include <ctime>
0044 #include <string>
0045 extern "C" {
0046 #if defined(_WIN32)
0047 # include <sys/stat.h>
0048 # ifdef FPTEX
0049 # include <win32lib.h>
0050 # else
0051 # ifndef NOMINMAX
0052 # define NOMINMAX
0053 # endif
0054 # include <windows.h>
0055 # endif
0056 #else
0057 # include <unistd.h>
0058 # include <sys/types.h>
0059 # if defined(HAVE_DIRENT_H)
0060 # include <dirent.h>
0061 # define NAMLEN(d) strlen((d)->d_name)
0062 # else
0063 # define dirent direct
0064 # define NAMLEN(d) (d)->d_namlen
0065 # ifdef HAVE_SYS_NDIR_H
0066 # include <sys/ndir.h>
0067 # endif
0068 # ifdef HAVE_SYS_DIR_H
0069 # include <sys/dir.h>
0070 # endif
0071 # ifdef HAVE_NDIR_H
0072 # include <ndir.h>
0073 # endif
0074 # endif
0075 #endif
0076 }
0077
0078 #include <memory>
0079
0080 class GooString;
0081
0082
0083 typedef long long Goffset;
0084
0085
0086
0087
0088
0089 extern GooString POPPLER_PRIVATE_EXPORT *appendToPath(GooString *path, const char *fileName);
0090
0091 #ifndef _WIN32
0092
0093
0094
0095 extern int POPPLER_PRIVATE_EXPORT openFileDescriptor(const char *path, int flags);
0096 #endif
0097
0098
0099
0100
0101 extern FILE POPPLER_PRIVATE_EXPORT *openFile(const char *path, const char *mode);
0102
0103
0104
0105 extern char POPPLER_PRIVATE_EXPORT *getLine(char *buf, int size, FILE *f);
0106
0107
0108 extern int POPPLER_PRIVATE_EXPORT Gfseek(FILE *f, Goffset offset, int whence);
0109 extern Goffset POPPLER_PRIVATE_EXPORT Gftell(FILE *f);
0110
0111
0112 extern Goffset GoffsetMax();
0113
0114
0115
0116
0117
0118 class POPPLER_PRIVATE_EXPORT GooFile
0119 {
0120 public:
0121 GooFile(const GooFile &) = delete;
0122 GooFile &operator=(const GooFile &other) = delete;
0123
0124 int read(char *buf, int n, Goffset offset) const;
0125 Goffset size() const;
0126
0127 static std::unique_ptr<GooFile> open(const std::string &fileName);
0128 #ifndef _WIN32
0129 static std::unique_ptr<GooFile> open(int fdA);
0130 #endif
0131
0132 #ifdef _WIN32
0133 static std::unique_ptr<GooFile> open(const wchar_t *fileName);
0134
0135 ~GooFile() { CloseHandle(handle); }
0136
0137
0138 bool modificationTimeChangedSinceOpen() const;
0139
0140 private:
0141 GooFile(HANDLE handleA);
0142 HANDLE handle;
0143 struct _FILETIME modifiedTimeOnOpen;
0144 #else
0145 ~GooFile() { close(fd); }
0146
0147 bool modificationTimeChangedSinceOpen() const;
0148
0149 private:
0150 explicit GooFile(int fdA);
0151 int fd;
0152 struct timespec modifiedTimeOnOpen;
0153 #endif
0154 };
0155
0156 #endif