temporaryDirectory

Returns a path to a temporary directory.

FileSystem.swift:648
iOS
13.0+
macOS
10.15+
tvOS
13.0+
watchOS
6.0+
var temporaryDirectory: FilePath { get async throws }

Returns

The path to a temporary directory.

Implementation details

On all platforms, this function first attempts to read the TMPDIR environment variable and returns that path, omitting trailing slashes. If that fails:

  • On Darwin this function uses confstr(3) and gets the value of _CS_DARWIN_USER_TEMP_DIR; the users temporary directory. Typically items are removed after three days if they are not accessed.

  • On Android this returns “/data/local/tmp”.

  • On other platforms this returns “/tmp”.