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 /* create a temporary filename */
90 char* mktmpname(char*ptr);
92 //------------------------------------------------------------------------
94 //------------------------------------------------------------------------
99 GDirEntry(char *dirPath, char *name1, GBool doStat);
101 GString *getName() { return name; }
102 GBool isDir() { return dir; }
106 GString *name; // dir/file name
107 GBool dir; // is it a directory?
113 GDir(char *name, GBool doStat1 = gTrue);
115 GDirEntry *getNextEntry();
120 GString *path; // directory path
121 GBool doStat; // call stat() for each entry?
128 DIR *dir; // the DIR structure from opendir()
130 GBool needParent; // need to return an entry for [-]