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>
31 # include <sys/types.h>
33 # include "vms_dirent.h"
36 # define NAMLEN(d) strlen((d)->d_name)
38 # define dirent direct
39 # define NAMLEN(d) (d)->d_namlen
41 # include <sys/ndir.h>
55 //------------------------------------------------------------------------
57 // Get home directory path.
58 extern GString *getHomeDir();
60 // Get current directory.
61 extern GString *getCurrentDir();
63 // Append a file name to a path string. <path> may be an empty
64 // string, denoting the current directory). Returns <path>.
65 extern GString *appendToPath(GString *path, char *fileName);
67 // Grab the path from the front of the file name. If there is no
68 // directory component in <fileName>, returns an empty string.
69 extern GString *grabPath(char *fileName);
71 // Is this an absolute path or file name?
72 extern GBool isAbsolutePath(char *path);
74 // Make this path absolute by prepending current directory (if path is
75 // relative) or prepending user's directory (if path starts with '~').
76 extern GString *makePathAbsolute(GString *path);
78 // Get the modification time for <fileName>. Returns 0 if there is an
80 extern time_t getModTime(char *fileName);
82 // Create a temporary file and open it for writing. If <ext> is not
83 // NULL, it will be used as the file name extension. Returns both the
84 // name and the file pointer. For security reasons, all writing
85 // should be done to the returned file pointer; the file may be
86 // reopened later for reading, but not for writing. The <mode> string
87 // should be "w" or "wb". Returns true on success.
88 extern GBool openTempFile(GString **name, FILE **f, char *mode, char *ext);
90 // Execute <command>. Returns true on success.
91 extern GBool executeCommand(char *cmd);
93 // Just like fgets, but handles Unix, Mac, and/or DOS end-of-line
95 extern char *getLine(char *buf, int size, FILE *f);
97 //------------------------------------------------------------------------
99 //------------------------------------------------------------------------
104 GDirEntry(char *dirPath, char *nameA, GBool doStat);
106 GString *getName() { return name; }
107 GBool isDir() { return dir; }
111 GString *name; // dir/file name
112 GBool dir; // is it a directory?
118 GDir(char *name, GBool doStatA = gTrue);
120 GDirEntry *getNextEntry();
125 GString *path; // directory path
126 GBool doStat; // call stat() for each entry?
133 DIR *dir; // the DIR structure from opendir()
135 GBool needParent; // need to return an entry for [-]
140 /* create a temporary filename */
141 char* mktmpname(char*ptr);