2 * (c) The GRASP/AQUA Project, Glasgow University, 1998
4 * $Id: directoryAux.c,v 1.2 1998/12/02 13:27:17 simonm Exp $
6 * Support functions for manipulating directories
12 #ifdef HAVE_SYS_TYPES_H
13 #include <sys/types.h>
16 #ifdef HAVE_SYS_STAT_H
25 openDir__(StgByteArray path)
30 /* Check for an actual directory */
31 while (stat(path, &sb) != 0) {
38 if (!S_ISDIR(sb.st_mode)) {
39 ghc_errtype = ERR_INAPPROPRIATETYPE;
40 ghc_errstr = "not a directory";
44 while ((dir = opendir(path)) == NULL) {
55 readDir__(StgAddr dir)
59 while ((d = readdir((DIR*)dir)) == NULL) {
61 (void) closedir((DIR*)dir);
63 } else if (errno != EINTR) {
66 (void) closedir((DIR*)dir);
75 get_dirent_d_name(StgAddr d)
77 return ((struct dirent*)d)->d_name;
80 StgInt const_F_OK( void ) { return F_OK; }
82 StgInt sizeof_stat( void ) { return sizeof(struct stat); }
84 StgInt prim_stat(StgAddr x, StgAddr y)
86 return stat((char*)x, (struct stat*)y);
91 get_stat_st_mode (StgAddr x)
93 return ((struct stat *)x)->st_mode;
98 get_stat_st_mtime(StgAddr x)
100 return ((struct stat *)x)->st_mtime;
104 set_stat_st_mtime(StgByteArray p, StgByteArray x)
106 ((unsigned long *)p)[0] = ((struct stat *)x)->st_mtime;
110 StgWord const_S_IRUSR( void ) { return S_IRUSR; }
111 StgWord const_S_IWUSR( void ) { return S_IWUSR; }
112 StgWord const_S_IXUSR( void ) { return S_IXUSR; }
115 prim_S_ISDIR( StgWord x )
121 prim_S_ISREG( StgWord x )