projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 2001-08-04 06:19:54 by ken]
[ghc-hetmet.git]
/
ghc
/
lib
/
std
/
Directory.hsc
diff --git
a/ghc/lib/std/Directory.hsc
b/ghc/lib/std/Directory.hsc
index
e3760e4
..
1ce5844
100644
(file)
--- a/
ghc/lib/std/Directory.hsc
+++ b/
ghc/lib/std/Directory.hsc
@@
-1,5
+1,5
@@
-- -----------------------------------------------------------------------------
-- -----------------------------------------------------------------------------
--- $Id: Directory.hsc,v 1.1 2001/01/11 17:25:57 simonmar Exp $
+-- $Id: Directory.hsc,v 1.13 2001/07/13 11:48:52 rrt Exp $
--
-- (c) The University of Glasgow, 1994-2000
--
--
-- (c) The University of Glasgow, 1994-2000
--
@@
-54,16
+54,18
@@
import Prelude -- Just to get it in the dependencies
import Time ( ClockTime(..) )
import Time ( ClockTime(..) )
+import PrelPosix
import PrelStorable
import PrelCString
import PrelMarshalAlloc
import PrelStorable
import PrelCString
import PrelMarshalAlloc
+import PrelCTypesISO
import PrelCTypes
import PrelCTypes
-import PrelPosixTypes
import PrelCError
import PrelPtr
import PrelIOBase
import PrelBase
import PrelCError
import PrelPtr
import PrelIOBase
import PrelBase
+#include "config.h"
#include <sys/stat.h>
#include <dirent.h>
#include <limits.h>
#include <sys/stat.h>
#include <dirent.h>
#include <limits.h>
@@
-206,7
+208,7
@@
removeFile path = do
throwErrnoIfMinus1Retry_ "removeFile" (unlink s)
{-
throwErrnoIfMinus1Retry_ "removeFile" (unlink s)
{-
-@renameDirectory old@ {\em new} changes the name of an existing
+@renameDirectory@ {\em old} {\em new} changes the name of an existing
directory from {\em old} to {\em new}. If the {\em new} directory
already exists, it is atomically replaced by the {\em old} directory.
If the {\em new} directory is neither the {\em old} directory nor an
directory from {\em old} to {\em new}. If the {\em new} directory
already exists, it is atomically replaced by the {\em old} directory.
If the {\em new} directory is neither the {\em old} directory nor an
@@
-344,17
+346,28
@@
getDirectoryContents path = do
where
loop :: Ptr CDir -> IO [String]
loop dir = do
where
loop :: Ptr CDir -> IO [String]
loop dir = do
+ resetErrno
p <- readdir dir
if (p /= nullPtr)
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
entries <- loop dir
return (entry:entries)
else do errno <- getErrno
if (errno == eINTR) then loop dir else do
throwErrnoIfMinus1_ "getDirectoryContents" $ closedir dir
- if (isValidErrno errno) -- EOF
- then throwErrno "getDirectoryContents"
- else return []
+#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"
{-
If the operating system has a notion of current directories,
{-
If the operating system has a notion of current directories,
@@
-541,4
+554,3
@@
foreign import ccall unsafe closedir :: Ptr CDir -> IO CInt
foreign import ccall unsafe stat :: UCString -> Ptr CStat -> IO CInt
type CDirent = ()
foreign import ccall unsafe stat :: UCString -> Ptr CStat -> IO CInt
type CDirent = ()
-type CStat = ()