source: trunk/poppler/mypoppler/goo/gfile.h @ 461

Last change on this file since 461 was 461, checked in by Silvan Scherrer, 11 years ago

poppler update to 0.14.2

File size: 4.3 KB
Line 
1//========================================================================
2//
3// gfile.h
4//
5// Miscellaneous file and directory name manipulation.
6//
7// Copyright 1996-2003 Glyph & Cog, LLC
8//
9//========================================================================
10
11//========================================================================
12//
13// Modified under the Poppler project - http://poppler.freedesktop.org
14//
15// All changes made under the Poppler project to this file are licensed
16// under GPL version 2 or later
17//
18// Copyright (C) 2006 Kristian HÞgsberg <krh@redhat.com>
19// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
20// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
21//
22// To see a description of the changes please see the Changelog file that
23// came with your tarball or type make ChangeLog if you are building from git
24//
25//========================================================================
26
27#ifndef GFILE_H
28#define GFILE_H
29
30#include <stdio.h>
31#include <stdlib.h>
32#include <stddef.h>
33extern "C" {
34#if defined(_WIN32)
35#  include <sys/stat.h>
36#  ifdef FPTEX
37#    include <win32lib.h>
38#  else
39#    include <windows.h>
40#  endif
41#elif defined(ACORN)
42#elif defined(MACOS)
43#  include <ctime.h>
44#else
45#  include <unistd.h>
46#  include <sys/types.h>
47#  ifdef VMS
48#    include "vms_dirent.h"
49#  elif HAVE_DIRENT_H
50#    include <dirent.h>
51#    define NAMLEN(d) strlen((d)->d_name)
52#  else
53#    define dirent direct
54#    define NAMLEN(d) (d)->d_namlen
55#    if HAVE_SYS_NDIR_H
56#      include <sys/ndir.h>
57#    endif
58#    if HAVE_SYS_DIR_H
59#      include <sys/dir.h>
60#    endif
61#    if HAVE_NDIR_H
62#      include <ndir.h>
63#    endif
64#    if HAVE_DIRECT_H
65#      include <direct.h>
66#    endif
67#  endif
68#endif
69}
70#include "gtypes.h"
71
72class GooString;
73
74//------------------------------------------------------------------------
75
76// Get home directory path.
77extern GooString *getHomeDir();
78
79// Get current directory.
80extern GooString *getCurrentDir();
81
82// Append a file name to a path string.  <path> may be an empty
83// string, denoting the current directory).  Returns <path>.
84extern GooString *appendToPath(GooString *path, char *fileName);
85
86// Grab the path from the front of the file name.  If there is no
87// directory component in <fileName>, returns an empty string.
88extern GooString *grabPath(char *fileName);
89
90// Is this an absolute path or file name?
91extern GBool isAbsolutePath(char *path);
92
93// Make this path absolute by prepending current directory (if path is
94// relative) or prepending user's directory (if path starts with '~').
95extern GooString *makePathAbsolute(GooString *path);
96
97// Get the modification time for <fileName>.  Returns 0 if there is an
98// error.
99extern time_t getModTime(char *fileName);
100
101// Create a temporary file and open it for writing.  If <ext> is not
102// NULL, it will be used as the file name extension.  Returns both the
103// name and the file pointer.  For security reasons, all writing
104// should be done to the returned file pointer; the file may be
105// reopened later for reading, but not for writing.  The <mode> string
106// should be "w" or "wb".  Returns true on success.
107extern GBool openTempFile(GooString **name, FILE **f, char *mode);
108
109// Execute <command>.  Returns true on success.
110extern GBool executeCommand(char *cmd);
111
112// Just like fgets, but handles Unix, Mac, and/or DOS end-of-line
113// conventions.
114extern char *getLine(char *buf, int size, FILE *f);
115
116//------------------------------------------------------------------------
117// GDir and GDirEntry
118//------------------------------------------------------------------------
119
120class GDirEntry {
121public:
122
123  GDirEntry(char *dirPath, char *nameA, GBool doStat);
124  ~GDirEntry();
125  GooString *getName() { return name; }
126  GooString *getFullPath() { return fullPath; }
127  GBool isDir() { return dir; }
128
129private:
130
131  GooString *name;              // dir/file name
132  GooString *fullPath;
133  GBool dir;                    // is it a directory?
134};
135
136class GDir {
137public:
138
139  GDir(char *name, GBool doStatA = gTrue);
140  ~GDir();
141  GDirEntry *getNextEntry();
142  void rewind();
143
144private:
145
146  GooString *path;              // directory path
147  GBool doStat;                 // call stat() for each entry?
148#if defined(_WIN32)
149  WIN32_FIND_DATA ffd;
150  HANDLE hnd;
151#elif defined(ACORN)
152#elif defined(MACOS)
153#else
154  DIR *dir;                     // the DIR structure from opendir()
155#ifdef VMS
156  GBool needParent;             // need to return an entry for [-]
157#endif
158#endif
159};
160
161#endif
Note: See TracBrowser for help on using the repository browser.