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

Last change on this file since 257 was 257, checked in by Eugene Romanenko, 13 years ago

PDF plugin: Poppler library updated to version 0.10.0

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