]>
git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/gfile.h
1 //========================================================================
5 // Miscellaneous file and directory name manipulation.
7 // Copyright 1996-2003 Glyph & Cog, LLC
9 //========================================================================
18 # include <sys/stat.h>
20 # include <win32lib.h>
29 # include <sys/types.h>
31 # include "vms_dirent.h"
34 # define NAMLEN(d) strlen((d)->d_name)
41 //------------------------------------------------------------------------
43 // Get home directory path.
44 extern GString
*getHomeDir();
46 // Get current directory.
47 extern GString
*getCurrentDir();
49 // Append a file name to a path string. <path> may be an empty
50 // string, denoting the current directory). Returns <path>.
51 extern GString
*appendToPath(GString
*path
, char *fileName
);
53 // Grab the path from the front of the file name. If there is no
54 // directory component in <fileName>, returns an empty string.
55 extern GString
*grabPath(char *fileName
);
57 // Is this an absolute path or file name?
58 extern GBool
isAbsolutePath(char *path
);
60 // Make this path absolute by prepending current directory (if path is
61 // relative) or prepending user's directory (if path starts with '~').
62 extern GString
*makePathAbsolute(GString
*path
);
64 // Get the modification time for <fileName>. Returns 0 if there is an
66 extern time_t getModTime(char *fileName
);
68 // Create a temporary file and open it for writing. If <ext> is not
69 // NULL, it will be used as the file name extension. Returns both the
70 // name and the file pointer. For security reasons, all writing
71 // should be done to the returned file pointer; the file may be
72 // reopened later for reading, but not for writing. The <mode> string
73 // should be "w" or "wb". Returns true on success.
74 extern GBool
openTempFile(GString
**name
, FILE **f
, char *mode
, char *ext
);
76 // Execute <command>. Returns true on success.
77 extern GBool
executeCommand(char *cmd
);
79 // Just like fgets, but handles Unix, Mac, and/or DOS end-of-line
81 extern char *getLine(char *buf
, int size
, FILE *f
);
83 //------------------------------------------------------------------------
85 //------------------------------------------------------------------------
90 GDirEntry(char *dirPath
, char *nameA
, GBool doStat
);
92 GString
*getName() { return name
; }
93 GBool
isDir() { return dir
; }
97 GString
*name
; // dir/file name
98 GBool dir
; // is it a directory?
104 GDir(char *name
, GBool doStatA
= gTrue
);
106 GDirEntry
*getNextEntry();
111 GString
*path
; // directory path
112 GBool doStat
; // call stat() for each entry?
119 DIR *dir
; // the DIR structure from opendir()
121 GBool needParent
; // need to return an entry for [-]