Kevin A. Foss wrote:
The advantage is that you don't have to deal with any C-isms at all and it should work on any GPC platform without worrying about the underlying stat() implementation.
Yes, that's better, thanks. I didn't know about these binding flags.
The problem (as noted in the comments) is that if the bind fails it thinks the file exists, which is a bit of a kludge. However I couldn't get around the problem that appeared when a user gives a name that is used by a directory. Frank's code using stat() correctly reports true for directories.
Well... but I think in most cases it would be more appropriate to return false for directories (I hadn't thought about this problem at all) because I'd usually call this functions before trying to open the file for reading or updating.
So, I think it would be better to return false if the binding fails. (As currently implemented, the binding will fail if the given file name is a directory, or the file doesn't exist and the directory isn't writable.)