Handles directories for paths, as well as explicit filenames.