Have main.tempdirectory use the name of the script/application.

Fall back to ‘SwiftShell’ if main.path is empty (running in a playground).
This commit is contained in:
Kare Morstol
2016-04-01 00:43:23 +02:00
parent eff36d83ec
commit db1bbc3c26
+2 -1
View File
@@ -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! + "/"