Merge pull request #1000 from mamabusi/storeCookieInDataHome
diff --git a/Foundation/NSHTTPCookieStorage.swift b/Foundation/NSHTTPCookieStorage.swift
index dd9f83e..470b582 100644
--- a/Foundation/NSHTTPCookieStorage.swift
+++ b/Foundation/NSHTTPCookieStorage.swift
@@ -65,7 +65,7 @@
guard !FileManager.default.fileExists(atPath: path) else { return true }
do {
- try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: false, attributes: nil)
+ try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil)
return true
} catch {
return false
@@ -77,7 +77,7 @@
return path + fileName
}
//if we were unable to create the desired directory, create the cookie file in the `pwd`
- return fileName
+ return FileManager.default.currentDirectoryPath + fileName
}
open var cookies: [HTTPCookie]? {
diff --git a/Foundation/Thread.swift b/Foundation/Thread.swift
index 80b4d4c..3990db0 100644
--- a/Foundation/Thread.swift
+++ b/Foundation/Thread.swift
@@ -24,7 +24,7 @@
internal class NSThreadSpecific<T: NSObject> {
private var key = _CFThreadSpecificKeyCreate()
- internal func get(_ generator: (Void) -> T) -> T {
+ internal func get(_ generator: () -> T) -> T {
if let specific = _CFThreadSpecificGet(key) {
return specific as! T
} else {
@@ -130,7 +130,7 @@
pthread_exit(nil)
}
- internal var _main: (Void) -> Void = {}
+ internal var _main: () -> Void = {}
#if os(OSX) || os(iOS) || CYGWIN
private var _thread: pthread_t? = nil
#elseif os(Linux) || os(Android)
diff --git a/TestFoundation/TestFileManager.swift b/TestFoundation/TestFileManager.swift
index c4c665f..ab43967 100644
--- a/TestFoundation/TestFileManager.swift
+++ b/TestFoundation/TestFileManager.swift
@@ -49,7 +49,10 @@
} catch _ {
XCTFail()
}
-
+
+ // Ensure attempting to create the directory again fails gracefully.
+ XCTAssertNil(try? fm.createDirectory(atPath: path, withIntermediateDirectories:false, attributes:nil))
+
var isDir = false
let exists = fm.fileExists(atPath: path, isDirectory: &isDir)
XCTAssertTrue(exists)