[m-users.] Bug in posix.readdir (fixed)

Volker Wysk post at volker-wysk.de
Fri Oct 11 23:06:48 AEDT 2019


Hi!

The readdir/4 predicate from the posix library is buggy. It returns an
"unknown error code" error for the end of the directory stream.

I've fixed it. I've changed the type from

:- pred readdir(dir::in, 
	        posix.result(string)::out, 
		io::di, io::uo) is det.

to

:- pred readdir(dir::in,
                posix.result(maybe(string))::out,
                io::di, io::uo) is det.


The new version returns "posix.ok(yes(File))" for a directory entry,
and "posix.ok(no)" for the end of the stream.

See the attached file. It should replace the posix.readdir.m file from
the posix library (after renaming from readdir to posix.readdir).

Cheers,
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: readdir.m
Type: text/x-matlab
Size: 2347 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20191011/1f91eef2/attachment.bin>


More information about the users mailing list