Files
swift-inotify/Tests/InotifyIntegrationTests/Utilities/withTempDir.swift
2026-03-12 00:22:17 +01:00

11 lines
394 B
Swift

import Foundation
func withTempDir(_ body: (String) async throws -> Void) async throws {
let dir = FileManager.default.temporaryDirectory
.appendingPathComponent("InotifyIntegrationTests-\(UUID().uuidString)")
.path
try FileManager.default.createDirectory(atPath: dir, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(atPath: dir) }
try await body(dir)
}