|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GFILE_H |
|
#define GFILE_H |
|
|
|
#include "poppler-config.h" |
|
#include "poppler_private_export.h" |
|
#include <cstdio> |
|
#include <cstdlib> |
|
#include <cstddef> |
|
#include <ctime> |
|
#include <string> |
|
extern "C" { |
|
#if defined(_WIN32) |
|
# include <sys/stat.h> |
|
# ifdef FPTEX |
|
# include <win32lib.h> |
|
# else |
|
# ifndef NOMINMAX |
|
# define NOMINMAX |
|
# endif |
|
# include <windows.h> |
|
# endif |
|
#else |
|
# include <unistd.h> |
|
# include <sys/types.h> |
|
# if defined(HAVE_DIRENT_H) |
|
# include <dirent.h> |
|
# define NAMLEN(d) strlen((d)->d_name) |
|
# else |
|
# define dirent direct |
|
# define NAMLEN(d) (d)->d_namlen |
|
# ifdef HAVE_SYS_NDIR_H |
|
# include <sys/ndir.h> |
|
# endif |
|
# ifdef HAVE_SYS_DIR_H |
|
# include <sys/dir.h> |
|
# endif |
|
# ifdef HAVE_NDIR_H |
|
# include <ndir.h> |
|
# endif |
|
# endif |
|
#endif |
|
} |
|
|
|
#include <memory> |
|
|
|
class GooString; |
|
|
|
|
|
typedef long long Goffset; |
|
|
|
|
|
|
|
|
|
|
|
extern GooString POPPLER_PRIVATE_EXPORT *appendToPath(GooString *path, const char *fileName); |
|
|
|
#ifndef _WIN32 |
|
|
|
|
|
|
|
extern int POPPLER_PRIVATE_EXPORT openFileDescriptor(const char *path, int flags); |
|
#endif |
|
|
|
|
|
|
|
|
|
extern FILE POPPLER_PRIVATE_EXPORT *openFile(const char *path, const char *mode); |
|
|
|
|
|
|
|
extern char POPPLER_PRIVATE_EXPORT *getLine(char *buf, int size, FILE *f); |
|
|
|
|
|
extern int POPPLER_PRIVATE_EXPORT Gfseek(FILE *f, Goffset offset, int whence); |
|
extern Goffset POPPLER_PRIVATE_EXPORT Gftell(FILE *f); |
|
|
|
|
|
extern Goffset GoffsetMax(); |
|
|
|
|
|
|
|
|
|
|
|
class POPPLER_PRIVATE_EXPORT GooFile |
|
{ |
|
public: |
|
GooFile(const GooFile &) = delete; |
|
GooFile &operator=(const GooFile &other) = delete; |
|
|
|
int read(char *buf, int n, Goffset offset) const; |
|
Goffset size() const; |
|
|
|
static std::unique_ptr<GooFile> open(const std::string &fileName); |
|
#ifndef _WIN32 |
|
static std::unique_ptr<GooFile> open(int fdA); |
|
#endif |
|
|
|
#ifdef _WIN32 |
|
static std::unique_ptr<GooFile> open(const wchar_t *fileName); |
|
|
|
~GooFile() { CloseHandle(handle); } |
|
|
|
|
|
bool modificationTimeChangedSinceOpen() const; |
|
|
|
private: |
|
GooFile(HANDLE handleA); |
|
HANDLE handle; |
|
struct _FILETIME modifiedTimeOnOpen; |
|
#else |
|
~GooFile() { close(fd); } |
|
|
|
bool modificationTimeChangedSinceOpen() const; |
|
|
|
private: |
|
explicit GooFile(int fdA); |
|
int fd; |
|
struct timespec modifiedTimeOnOpen; |
|
#endif |
|
}; |
|
|
|
#endif |
|
|