From db1bbc3c266cbf5ea2bc3b3b407d92a587fa192f Mon Sep 17 00:00:00 2001 From: Kare Morstol Date: Fri, 1 Apr 2016 00:43:23 +0200 Subject: [PATCH] Have main.tempdirectory use the name of the script/application. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fall back to ‘SwiftShell’ if main.path is empty (running in a playground). --- Sources/SwiftShell/Context.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftShell/Context.swift b/Sources/SwiftShell/Context.swift index 038c49d..4bc7112 100644 --- a/Sources/SwiftShell/Context.swift +++ b/Sources/SwiftShell/Context.swift @@ -72,7 +72,8 @@ extension ShellContext: ShellRunnable { private func createTempdirectory () -> String { - let tempdirectory = NSURL(fileURLWithPath:NSTemporaryDirectory()) + ("SwiftShell-" + NSProcessInfo.processInfo().globallyUniqueString) + let name = NSURL(fileURLWithPath: main.path).lastPathComponent ?? "SwiftShell" + let tempdirectory = NSURL(fileURLWithPath:NSTemporaryDirectory()) + (name + "-" + NSProcessInfo.processInfo().globallyUniqueString) do { try Files.createDirectoryAtPath(tempdirectory.path!, withIntermediateDirectories: true, attributes: nil) return tempdirectory.path! + "/"