TemporaryFile

struct TemporaryFile

A wrapper around a temporary file in a temporary directory. The directory has been especially created for the file, so it’s safe to delete when you’re done working with the file.

Call deleteDirectory when you no longer need the file.

  • This will be the URL that references the directory, itself.

    Declaration

    Swift

    let directoryURL: URL
  • This will be the URL to the file (once it’s created).

    Declaration

    Swift

    let fileURL: URL
  • Deletes the temporary directory and all files in it.

    Declaration

    Swift

    let deleteDirectory: () throws -> Void
  • Creates a temporary directory with a unique name and initializes the receiver with a fileURL representing a file named filename in that directory.

    Note

    This doesn’t create the file!

    Declaration

    Swift

    init(creatingTempDirectoryForFilename filename: String) throws