2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: fileSize.c,v 1.3 1998/12/02 13:27:30 simonm Exp $
6 * hClose Runtime Support
12 #ifdef HAVE_SYS_TYPES_H
13 #include <sys/types.h>
16 #ifdef HAVE_SYS_STAT_H
25 IOFileObject* fo = (IOFileObject*)ptr;
29 /* Flush buffer in order to get as an accurate size as poss. */
31 if (rc < 0) return rc;
33 while (fstat(fo->fd, &sb) < 0) {
41 if (S_ISREG(sb.st_mode)) {
42 /* result will be word aligned */
43 *(off_t *) result = sb.st_size;
46 ghc_errtype = ERR_INAPPROPRIATETYPE;
47 ghc_errstr = "not a regular file";
53 fileSize_int64(ptr, result)
57 IOFileObject* fo = (IOFileObject*)ptr;
61 /* Flush buffer in order to get as an accurate size as poss. */
63 if (rc < 0) return rc;
65 while (fstat(fo->fd, &sb) < 0) {
73 if (S_ISREG(sb.st_mode)) {
74 /* result will be word aligned */
75 *(StgInt64*) result = (StgInt64)sb.st_size;
78 ghc_errtype = ERR_INAPPROPRIATETYPE;
79 ghc_errstr = "not a regular file";