Get the correct kind of file object.