Added function to create parent directory when visiting file in non-existent directory