[m-users.] Reading the entire directory contents (contribution for the posix library)

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


Hi!

Using opendir, readdir and closedir from the posix library, I've
written a little code to read the entire contents of a directory.

It's this predicate:

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

It takes the name of the directory and returns the contents of it.

The contents are sorted, such that the "." and ".." entries are at thebeginning. 

I'd like to have this in the posix library. 

Bye
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dir_contents.m
Type: text/x-objcsrc
Size: 1701 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20191011/5fcca0bf/attachment.bin>


More information about the users mailing list