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

Last change on this file since 497 was 497, checked in by Silvan Scherrer, 10 years ago

Lucide: updated fontconfig and poppler

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