File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,20 @@ import Darwin
15
15
import Glibc
16
16
#endif
17
17
18
+ public func NSTemporaryDirectory( ) -> String {
19
+ #if os(OSX) || os(iOS)
20
+ var buf = [ Int8] ( count: 100 , repeatedValue: 0 )
21
+ let r = confstr ( _CS_DARWIN_USER_TEMP_DIR, & buf, buf. count)
22
+ if r != 0 && r < buf. count {
23
+ return String ( CString: buf, encoding: NSUTF8StringEncoding) !
24
+ }
25
+ #endif
26
+ if let tmpdir = NSProcessInfo . processInfo ( ) . environment [ " TMPDIR " ] {
27
+ return tmpdir
28
+ }
29
+ return " /tmp/ "
30
+ }
31
+
18
32
internal extension String {
19
33
20
34
internal var _startOfLastPathComponent : String . CharacterView . Index {
Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ class TestNSURL : XCTestCase {
225
225
226
226
}
227
227
228
- static let gBaseTemporaryDirectoryPath = " /tmp/ " // TODO: NSTemporaryDirectory()
228
+ static let gBaseTemporaryDirectoryPath = NSTemporaryDirectory ( )
229
229
static var gBaseCurrentWorkingDirectoryPath : String {
230
230
let count = Int ( 1024 ) // MAXPATHLEN is platform specific; this is the lowest common denominator for darwin and most linuxes
231
231
var buf : [ Int8 ] = Array ( count: count, repeatedValue: 0 )
You can’t perform that action at this time.
0 commit comments