-- -----------------------------------------------------------------------------
--- $Id: Directory.hsc,v 1.5 2001/02/13 15:23:33 rrt Exp $
+-- $Id: Directory.hsc,v 1.10 2001/04/02 16:10:32 rrt Exp $
--
-- (c) The University of Glasgow, 1994-2000
--
import PrelIOBase
import PrelBase
+-- Fix mingw stat problem
+#include "../includes/config.h"
#include <sys/stat.h>
#include <dirent.h>
#include <limits.h>
resetErrno
p <- readdir dir
if (p /= nullPtr)
- then do entry <- peekCString ((#ptr struct dirent,d_name) p)
+ then do
+#ifndef mingw32_TARGET_OS
+ entry <- peekCString ((#ptr struct dirent,d_name) p)
+#else
+ entryp <- (#peek struct dirent,d_name) p
+ entry <- peekCString entryp -- on mingwin it's a char *, not a char []
+#endif
entries <- loop dir
return (entry:entries)
else do errno <- getErrno
if (errno == eINTR) then loop dir else do
throwErrnoIfMinus1_ "getDirectoryContents" $ closedir dir
+#ifndef mingw32_TARGET_OS
if (errno == eOK)
+#else
+ if (errno == eNOENT) -- mingwin (20001111) cunningly sets errno to ENOENT when it runs out of files
+#endif
then return []
else throwErrno "getDirectoryContents"