Prepare for writing a file to the given path – create ancestor directories and verify no directory exists in the path