New API. A function to atomically create a file.