Listing regular files with directory_member/2

Currently, using the option file_type(regular) causes directory_member/2 to fail without any solutions, no matter what is in that directory.

$ mkdir foo
$ cd foo
$ touch a b c
$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.31-38-ga65b7469e-DIRTY)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- directory_member(., M, [file_type(regular)]).
false.

It seems that this has been noticed already two years ago. With that change, the specific use case works correctly:

?- directory_member(., M, [file_type(regular)]).
M = a ;
M = c ;
M = b.

Is there any problem with the linked PR? Can it be merged or does it need improvement?

1 Like

It was just missed :frowning: Merged. Thanks for reviving this.

2 Likes