2 * (c) The GRASP/AQUA Project, Glasgow University, 1998
4 * $Id: directoryAux.c,v 1.3 2000/08/24 10:27:01 simonmar 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 sizeof_stat( void ) { return sizeof(struct stat); }
82 StgInt prim_stat(StgAddr x, StgAddr y)
84 return stat((char*)x, (struct stat*)y);
89 get_stat_st_mode (StgAddr x)
91 return ((struct stat *)x)->st_mode;
96 get_stat_st_mtime(StgAddr x)
98 return ((struct stat *)x)->st_mtime;
102 set_stat_st_mtime(StgByteArray p, StgByteArray x)
104 ((unsigned long *)p)[0] = ((struct stat *)x)->st_mtime;
108 StgWord const_S_IRUSR( void ) { return S_IRUSR; }
109 StgWord const_S_IWUSR( void ) { return S_IWUSR; }
110 StgWord const_S_IXUSR( void ) { return S_IXUSR; }
113 prim_S_ISDIR( StgWord x )
119 prim_S_ISREG( StgWord x )
125 StgWord const_R_OK( void ) { return R_OK; }
126 StgWord const_W_OK( void ) { return W_OK; }
127 StgWord const_X_OK( void ) { return X_OK; }
128 StgWord const_F_OK( void ) { return F_OK; }