From http://pubs.opengroup.org/onlinepubs/7908799/xsh/fopen.html:
The fopen() function will fail if:
[EISDIR] The named file is a directory and mode requires write access.
At least on Linux, if you try to fopen("dirname", "wb")
you get an EISDIR error. I also tried with a directory with d——– access rights, and I still get EISDIR (and not EACCES.)