It seems like this method and createFileHandle have a lot of logic in common.  If possible, we should combine them.