1 //========================================================================
5 // Miscellaneous file and directory name manipulation.
7 // Copyright 1996 Derek B. Noonburg
9 //========================================================================
17 #include "../../config.h"
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 GString *makePathAbsolute(GString *path);
77 // Get the modification time for <fileName>. Returns 0 if there is an
79 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 GBool openTempFile(GString **name, FILE **f, char *mode, char *ext);
89 //------------------------------------------------------------------------
91 //------------------------------------------------------------------------
96 GDirEntry(char *dirPath, char *name1, GBool doStat);
98 GString *getName() { return name; }
99 GBool isDir() { return dir; }
103 GString *name; // dir/file name
104 GBool dir; // is it a directory?
110 GDir(char *name, GBool doStat1 = gTrue);
112 GDirEntry *getNextEntry();
117 GString *path; // directory path
118 GBool doStat; // call stat() for each entry?
125 DIR *dir; // the DIR structure from opendir()
127 GBool needParent; // need to return an entry for [-]