Skip to content
Snippets Groups Projects
Commit ffff0c11 authored by sof's avatar sof
Browse files

[project @ 1998-04-30 19:51:07 by sof]

tidyup
parent 009527af
No related merge requests found
...@@ -337,15 +337,14 @@ The path refers to an existing non-directory object. ...@@ -337,15 +337,14 @@ The path refers to an existing non-directory object.
--getDirectoryContents :: FilePath -> IO [FilePath] --getDirectoryContents :: FilePath -> IO [FilePath]
getDirectoryContents path = do getDirectoryContents path = do
dir <- _ccall_ openDir__ path dir <- _ccall_ openDir__ path
ptr <- _ccall_ malloc (``sizeof(struct dirent**)''::Int)
if dir == ``NULL'' if dir == ``NULL''
then constructErrorAndFail "getDirectoryContents" then constructErrorAndFail "getDirectoryContents"
else loop dir ptr else loop dir
where where
loop :: Addr -> Addr -> IO [String] loop :: Addr -> IO [String]
loop dir dirent_ptr = do loop dir = do
dirent_ptr <- _ccall_ readDir__ dir dirent_ptr <- _ccall_ readDir__ dir
if dirent_ptr == ``NULL'' if (dirent_ptr::Addr) == ``NULL''
then do then do
return [] return []
else do else do
...@@ -355,7 +354,7 @@ getDirectoryContents path = do ...@@ -355,7 +354,7 @@ getDirectoryContents path = do
-- calls to readdir() may overwrite it. -- calls to readdir() may overwrite it.
len <- _ccall_ strlen str len <- _ccall_ strlen str
entry <- stToIO (unpackNBytesST str len) entry <- stToIO (unpackNBytesST str len)
entries <- loop dir dirent_ptr entries <- loop dir
return (entry:entries) return (entry:entries)
\end{code} \end{code}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment