Exists_file/1 in v9.0.4 is broken

Hi Jan,

v5.9.7:

1 ?- exists_file('').
false.

v.9.0.4:

?- exists_file('').
ERROR: Domain error: `foreign_return_value' expected, found `-1'
ERROR: In:
ERROR:   [10] exists_file('')
ERROR:    [9] toplevel_call(user:user: ...) at c:/programs/swi-prolog/v9.0.4-1/boot/toplevel.pl:1173

I think the v.5.9.7 is right.

Cheers
Holger

The error is surely wrong. It doesn’t reproduce, neither under Wine nor on Windows 11. It is quite easy to see why this could happen though. Pushed a fix and documented the behavior that using an illegal name (such as a too long name) causes this predicate to fail silently.

I don’t know whether that is good or bad. On the one hand one could argue that it is better to raise an appropriate exception for an invalid name. On the other hand, we have seen that the Windows error codes are often wrong. And, one could argue that there is indeed no file with that name because the name is invalid and (thus) that file cannot exist. This, while it could exist on another system that can represent the file name.

Hi Jan,

thanks for the quick support!

Cheers
Holger