author | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
commit | 98a1e3f36567639344f12932b629e526a8783aa8 (patch) (unidiff) | |
tree | 0433d296857faceeafc54f7deabddb621f45a933 /noncore/unsupported/qpdf/goo/gfile.h | |
parent | 7e31b1fba119f69929d6744d7295555ff1727f4f (diff) | |
download | opie-98a1e3f36567639344f12932b629e526a8783aa8.zip opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.gz opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.bz2 |
CVS import of QPdf
Diffstat (limited to 'noncore/unsupported/qpdf/goo/gfile.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/goo/gfile.h | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/goo/gfile.h b/noncore/unsupported/qpdf/goo/gfile.h new file mode 100644 index 0000000..16cbca0 --- a/dev/null +++ b/noncore/unsupported/qpdf/goo/gfile.h | |||
@@ -0,0 +1,135 @@ | |||
1 | //======================================================================== | ||
2 | // | ||
3 | // gfile.h | ||
4 | // | ||
5 | // Miscellaneous file and directory name manipulation. | ||
6 | // | ||
7 | // Copyright 1996 Derek B. Noonburg | ||
8 | // | ||
9 | //======================================================================== | ||
10 | |||
11 | #ifndef GFILE_H | ||
12 | #define GFILE_H | ||
13 | |||
14 | #include <stdio.h> | ||
15 | #include <stdlib.h> | ||
16 | #include <stddef.h> | ||
17 | #if defined(WIN32) | ||
18 | # include <sys/stat.h> | ||
19 | # ifdef FPTEX | ||
20 | # include <win32lib.h> | ||
21 | # else | ||
22 | # include <windows.h> | ||
23 | # endif | ||
24 | #elif defined(ACORN) | ||
25 | #elif defined(MACOS) | ||
26 | # include <ctime.h> | ||
27 | #else | ||
28 | # include <unistd.h> | ||
29 | # include <sys/types.h> | ||
30 | # ifdef VMS | ||
31 | # include "vms_dirent.h" | ||
32 | # elif HAVE_DIRENT_H | ||
33 | # include <dirent.h> | ||
34 | # define NAMLEN(d) strlen((d)->d_name) | ||
35 | # else | ||
36 | # define dirent direct | ||
37 | # define NAMLEN(d) (d)->d_namlen | ||
38 | # if HAVE_SYS_NDIR_H | ||
39 | # include <sys/ndir.h> | ||
40 | # endif | ||
41 | # if HAVE_SYS_DIR_H | ||
42 | # include <sys/dir.h> | ||
43 | # endif | ||
44 | # if HAVE_NDIR_H | ||
45 | # include <ndir.h> | ||
46 | # endif | ||
47 | # endif | ||
48 | #endif | ||
49 | #include "gtypes.h" | ||
50 | |||
51 | class GString; | ||
52 | |||
53 | //------------------------------------------------------------------------ | ||
54 | |||
55 | // Get home directory path. | ||
56 | extern GString *getHomeDir(); | ||
57 | |||
58 | // Get current directory. | ||
59 | extern GString *getCurrentDir(); | ||
60 | |||
61 | // Append a file name to a path string. <path> may be an empty | ||
62 | // string, denoting the current directory). Returns <path>. | ||
63 | extern GString *appendToPath(GString *path, char *fileName); | ||
64 | |||
65 | // Grab the path from the front of the file name. If there is no | ||
66 | // directory component in <fileName>, returns an empty string. | ||
67 | extern GString *grabPath(char *fileName); | ||
68 | |||
69 | // Is this an absolute path or file name? | ||
70 | extern GBool isAbsolutePath(char *path); | ||
71 | |||
72 | // Make this path absolute by prepending current directory (if path is | ||
73 | // relative) or prepending user's directory (if path starts with '~'). | ||
74 | extern GString *makePathAbsolute(GString *path); | ||
75 | |||
76 | // Get the modification time for <fileName>. Returns 0 if there is an | ||
77 | // error. | ||
78 | extern time_t getModTime(char *fileName); | ||
79 | |||
80 | // Create a temporary file and open it for writing. If <ext> is not | ||
81 | // NULL, it will be used as the file name extension. Returns both the | ||
82 | // name and the file pointer. For security reasons, all writing | ||
83 | // should be done to the returned file pointer; the file may be | ||
84 | // reopened later for reading, but not for writing. The <mode> string | ||
85 | // should be "w" or "wb". Returns true on success. | ||
86 | extern GBool openTempFile(GString **name, FILE **f, char *mode, char *ext); | ||
87 | |||
88 | // Just like fgets, but handles Unix, Mac, and/or DOS end-of-line | ||
89 | // conventions. | ||
90 | extern char *getLine(char *buf, int size, FILE *f); | ||
91 | |||
92 | //------------------------------------------------------------------------ | ||
93 | // GDir and GDirEntry | ||
94 | //------------------------------------------------------------------------ | ||
95 | |||
96 | class GDirEntry { | ||
97 | public: | ||
98 | |||
99 | GDirEntry(char *dirPath, char *nameA, GBool doStat); | ||
100 | ~GDirEntry(); | ||
101 | GString *getName() { return name; } | ||
102 | GBool isDir() { return dir; } | ||
103 | |||
104 | private: | ||
105 | |||
106 | GString *name; // dir/file name | ||
107 | GBool dir; // is it a directory? | ||
108 | }; | ||
109 | |||
110 | class GDir { | ||
111 | public: | ||
112 | |||
113 | GDir(char *name, GBool doStatA = gTrue); | ||
114 | ~GDir(); | ||
115 | GDirEntry *getNextEntry(); | ||
116 | void rewind(); | ||
117 | |||
118 | private: | ||
119 | |||
120 | GString *path; // directory path | ||
121 | GBool doStat; // call stat() for each entry? | ||
122 | #if defined(WIN32) | ||
123 | WIN32_FIND_DATA ffd; | ||
124 | HANDLE hnd; | ||
125 | #elif defined(ACORN) | ||
126 | #elif defined(MACOS) | ||
127 | #else | ||
128 | DIR *dir; // the DIR structure from opendir() | ||
129 | #ifdef VMS | ||
130 | GBool needParent; // need to return an entry for [-] | ||
131 | #endif | ||
132 | #endif | ||
133 | }; | ||
134 | |||
135 | #endif | ||