From 659ec263572821f752f87ea4f7e4c13fcdd20461 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Thu, 10 Sep 2015 06:46:36 +0000 Subject: poppler 0.36.0 git-svn-id: svn://tug.org/texlive/trunk@38335 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/libs/poppler/poppler-0.36.0/goo/gfile.h | 209 +++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 Build/source/libs/poppler/poppler-0.36.0/goo/gfile.h (limited to 'Build/source/libs/poppler/poppler-0.36.0/goo/gfile.h') diff --git a/Build/source/libs/poppler/poppler-0.36.0/goo/gfile.h b/Build/source/libs/poppler/poppler-0.36.0/goo/gfile.h new file mode 100644 index 00000000000..1365a9cf2ab --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.36.0/goo/gfile.h @@ -0,0 +1,209 @@ +//======================================================================== +// +// gfile.h +// +// Miscellaneous file and directory name manipulation. +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2006 Kristian Høgsberg +// Copyright (C) 2009, 2011, 2012 Albert Astals Cid +// Copyright (C) 2009 Kovid Goyal +// Copyright (C) 2013 Adam Reichold +// Copyright (C) 2013 Adrian Johnson +// Copyright (C) 2014 Bogdan Cristea +// Copyright (C) 2014 Peter Breitenlohner +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef GFILE_H +#define GFILE_H + +#include "poppler-config.h" +#include +#include +#include +extern "C" { +#if defined(_WIN32) +# include +# ifdef FPTEX +# include +# else +# ifndef NOMINMAX +# define NOMINMAX +# endif +# include +# endif +#elif defined(ACORN) +#elif defined(MACOS) +# include +#else +# include +# include +# ifdef VMS +# include "vms_dirent.h" +# elif HAVE_DIRENT_H +# include +# define NAMLEN(d) strlen((d)->d_name) +# else +# define dirent direct +# define NAMLEN(d) (d)->d_namlen +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif +# endif +#endif +} +#include "gtypes.h" + +class GooString; + +//------------------------------------------------------------------------ + +// Get current directory. +extern GooString *getCurrentDir(); + +// Append a file name to a path string. may be an empty +// string, denoting the current directory). Returns . +extern GooString *appendToPath(GooString *path, const char *fileName); + +// Grab the path from the front of the file name. If there is no +// directory component in , returns an empty string. +extern GooString *grabPath(char *fileName); + +// Is this an absolute path or file name? +extern GBool isAbsolutePath(char *path); + +// Get the modification time for . Returns 0 if there is an +// error. +extern time_t getModTime(char *fileName); + +// Create a temporary file and open it for writing. If is not +// NULL, it will be used as the file name extension. Returns both the +// name and the file pointer. For security reasons, all writing +// should be done to the returned file pointer; the file may be +// reopened later for reading, but not for writing. The string +// should be "w" or "wb". Returns true on success. +extern GBool openTempFile(GooString **name, FILE **f, const char *mode); + +#ifdef WIN32 +// Convert a file name from Latin-1 to UTF-8. +extern GooString *fileNameToUTF8(char *path); + +// Convert a file name from UCS-2 to UTF-8. +extern GooString *fileNameToUTF8(wchar_t *path); +#endif + +// 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. +extern FILE *openFile(const char *path, const char *mode); + +// Just like fgets, but handles Unix, Mac, and/or DOS end-of-line +// conventions. +extern char *getLine(char *buf, int size, FILE *f); + +// Like fseek/ftell but uses platform specific variants that support large files +extern int Gfseek(FILE *f, Goffset offset, int whence); +extern Goffset Gftell(FILE *f); + +// Largest offset supported by Gfseek/Gftell +extern Goffset GoffsetMax(); + +//------------------------------------------------------------------------ +// GooFile +//------------------------------------------------------------------------ + +class GooFile +{ +public: + int read(char *buf, int n, Goffset offset) const; + Goffset size() const; + + static GooFile *open(const GooString *fileName); + +#ifdef _WIN32 + static GooFile *open(const wchar_t *fileName); + + ~GooFile() { CloseHandle(handle); } + +private: + GooFile(HANDLE handleA): handle(handleA) {} + HANDLE handle; +#else + ~GooFile() { close(fd); } + +private: + GooFile(int fdA) : fd(fdA) {} + int fd; +#endif // _WIN32 +}; + +//------------------------------------------------------------------------ +// GDir and GDirEntry +//------------------------------------------------------------------------ + +class GDirEntry { +public: + + GDirEntry(char *dirPath, char *nameA, GBool doStat); + ~GDirEntry(); + GooString *getName() { return name; } + GooString *getFullPath() { return fullPath; } + GBool isDir() { return dir; } + +private: + GDirEntry(const GDirEntry &other); + GDirEntry& operator=(const GDirEntry &other); + + GooString *name; // dir/file name + GooString *fullPath; + GBool dir; // is it a directory? +}; + +class GDir { +public: + + GDir(char *name, GBool doStatA = gTrue); + ~GDir(); + GDirEntry *getNextEntry(); + void rewind(); + +private: + GDir(const GDir &other); + GDir& operator=(const GDir &other); + + GooString *path; // directory path + GBool doStat; // call stat() for each entry? +#if defined(_WIN32) + WIN32_FIND_DATA ffd; + HANDLE hnd; +#elif defined(ACORN) +#elif defined(MACOS) +#else + DIR *dir; // the DIR structure from opendir() +#ifdef VMS + GBool needParent; // need to return an entry for [-] +#endif +#endif +}; + +#endif -- cgit v1.2.3