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

Last change on this file since 134 was 134, checked in by Eugene Romanenko, 15 years ago

poppler updated to version 0.5.4

File size: 3.8 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#ifndef GFILE_H
12#define GFILE_H
13
14#include <stdio.h>
15#include <stdlib.h>
16#include <stddef.h>
17extern "C" {
18#if defined(WIN32)
19#  include <sys/stat.h>
20#  ifdef FPTEX
21#    include <win32lib.h>
22#  else
23#    include <windows.h>
24#  endif
25#elif defined(ACORN)
26#elif defined(MACOS)
27#  include <ctime.h>
28#else
29#  include <unistd.h>
30#  include <sys/types.h>
31#  ifdef VMS
32#    include "vms_dirent.h"
33#  elif HAVE_DIRENT_H
34#    include <dirent.h>
35#    define NAMLEN(d) strlen((d)->d_name)
36#  else
37#    define dirent direct
38#    define NAMLEN(d) (d)->d_namlen
39#    if HAVE_SYS_NDIR_H
40#      include <sys/ndir.h>
41#    endif
42#    if HAVE_SYS_DIR_H
43#      include <sys/dir.h>
44#    endif
45#    if HAVE_NDIR_H
46#      include <ndir.h>
47#    endif
48#    if HAVE_DIRECT_H
49#      include <direct.h>
50#    endif
51#  endif
52#endif
53}
54#include "gtypes.h"
55
56class GooString;
57
58//------------------------------------------------------------------------
59
60// Get home directory path.
61extern GooString *getHomeDir();
62
63// Get current directory.
64extern GooString *getCurrentDir();
65
66// Append a file name to a path string.  <path> may be an empty
67// string, denoting the current directory).  Returns <path>.
68extern GooString *appendToPath(GooString *path, char *fileName);
69
70// Grab the path from the front of the file name.  If there is no
71// directory component in <fileName>, returns an empty string.
72extern GooString *grabPath(char *fileName);
73
74// Is this an absolute path or file name?
75extern GBool isAbsolutePath(char *path);
76
77// Make this path absolute by prepending current directory (if path is
78// relative) or prepending user's directory (if path starts with '~').
79extern GooString *makePathAbsolute(GooString *path);
80
81// Get the modification time for <fileName>.  Returns 0 if there is an
82// error.
83extern time_t getModTime(char *fileName);
84
85// Create a temporary file and open it for writing.  If <ext> is not
86// NULL, it will be used as the file name extension.  Returns both the
87// name and the file pointer.  For security reasons, all writing
88// should be done to the returned file pointer; the file may be
89// reopened later for reading, but not for writing.  The <mode> string
90// should be "w" or "wb".  Returns true on success.
91extern GBool openTempFile(GooString **name, FILE **f, char *mode, char *ext);
92
93// Execute <command>.  Returns true on success.
94extern GBool executeCommand(char *cmd);
95
96// Just like fgets, but handles Unix, Mac, and/or DOS end-of-line
97// conventions.
98extern char *getLine(char *buf, int size, FILE *f);
99
100//------------------------------------------------------------------------
101// GDir and GDirEntry
102//------------------------------------------------------------------------
103
104class GDirEntry {
105public:
106
107  GDirEntry(char *dirPath, char *nameA, GBool doStat);
108  ~GDirEntry();
109  GooString *getName() { return name; }
110  GooString *getFullPath() { return fullPath; }
111  GBool isDir() { return dir; }
112
113private:
114
115  GooString *name;              // dir/file name
116  GooString *fullPath;
117  GBool dir;                    // is it a directory?
118};
119
120class GDir {
121public:
122
123  GDir(char *name, GBool doStatA = gTrue);
124  ~GDir();
125  GDirEntry *getNextEntry();
126  void rewind();
127
128private:
129
130  GooString *path;              // directory path
131  GBool doStat;                 // call stat() for each entry?
132#if defined(WIN32)
133  WIN32_FIND_DATA ffd;
134  HANDLE hnd;
135#elif defined(ACORN)
136#elif defined(MACOS)
137#else
138  DIR *dir;                     // the DIR structure from opendir()
139#ifdef VMS
140  GBool needParent;             // need to return an entry for [-]
141#endif
142#endif
143};
144
145#endif
Note: See TracBrowser for help on using the repository browser.