1 //========================================================================
5 // Miscellaneous file and directory name manipulation.
7 // Copyright 1996-2002 Glyph & Cog, LLC
9 //========================================================================
19 # include <sys/stat.h>
21 # include <win32lib.h>
30 # include <sys/types.h>
32 # include "vms_dirent.h"
35 # define NAMLEN(d) strlen((d)->d_name)
37 # define dirent direct
38 # define NAMLEN(d) (d)->d_namlen
40 # include <sys/ndir.h>
54 //------------------------------------------------------------------------
56 // Get home directory path.
57 extern GString *getHomeDir();
59 // Get current directory.
60 extern GString *getCurrentDir();
62 // Append a file name to a path string. <path> may be an empty
63 // string, denoting the current directory). Returns <path>.
64 extern GString *appendToPath(GString *path, char *fileName);
66 // Grab the path from the front of the file name. If there is no
67 // directory component in <fileName>, returns an empty string.
68 extern GString *grabPath(char *fileName);
70 // Is this an absolute path or file name?
71 extern GBool isAbsolutePath(char *path);
73 // Make this path absolute by prepending current directory (if path is
74 // relative) or prepending user's directory (if path starts with '~').
75 extern GString *makePathAbsolute(GString *path);
77 // Get the modification time for <fileName>. Returns 0 if there is an
79 extern time_t getModTime(char *fileName);
81 // Create a temporary file and open it for writing. If <ext> is not
82 // NULL, it will be used as the file name extension. Returns both the
83 // name and the file pointer. For security reasons, all writing
84 // should be done to the returned file pointer; the file may be
85 // reopened later for reading, but not for writing. The <mode> string
86 // should be "w" or "wb". Returns true on success.
87 extern GBool openTempFile(GString **name, FILE **f, char *mode, char *ext);
89 // Execute <command>. Returns true on success.
90 extern GBool executeCommand(char *cmd);
92 // Just like fgets, but handles Unix, Mac, and/or DOS end-of-line
94 extern char *getLine(char *buf, int size, FILE *f);
96 //------------------------------------------------------------------------
98 //------------------------------------------------------------------------
103 GDirEntry(char *dirPath, char *nameA, GBool doStat);
105 GString *getName() { return name; }
106 GBool isDir() { return dir; }
110 GString *name; // dir/file name
111 GBool dir; // is it a directory?
117 GDir(char *name, GBool doStatA = gTrue);
119 GDirEntry *getNextEntry();
124 GString *path; // directory path
125 GBool doStat; // call stat() for each entry?
132 DIR *dir; // the DIR structure from opendir()
134 GBool needParent; // need to return an entry for [-]
139 /* create a temporary filename */
140 char* mktmpname(char*ptr);