fix various fs correctness and perf issues

This is a grab-bag of fs correctness and perf improvements. It'll be easier to review each individual commit separately.

This is going to allow calling openImpl on a directory, but there are conditions in the Connection class that check if a path is a directory before opening a FCOutputStream, so we should be good.