Skip to content

Commit c7d6685

Browse files
committed
Rename deprecated attributes
1 parent dab9598 commit c7d6685

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

Sources/Foundation/NSURL.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ extension NSURL {
911911
#if os(WASI)
912912
return nil
913913
#else
914-
let workingDir = FileManager.default.currentDirectoryPath
914+
let workingDir = FileManager.default.currentDirectoryURL
915915
absolutePath = workingDir._bridgeToObjectiveC().appendingPathComponent(selfPath)
916916
#endif
917917
}

Sources/Foundation/Process.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ open class Process: NSObject {
289289
}
290290
}
291291

292-
private var _currentDirectoryPath = FileManager.default.currentDirectoryPath
292+
private var _currentDirectoryPath = FileManager.default.currentDirectoryURL
293293
open var currentDirectoryURL: URL? {
294294
get { _currentDirectoryPath == "" ? nil : URL(fileURLWithPath: _currentDirectoryPath, isDirectory: true) }
295295
set {
@@ -298,7 +298,7 @@ open class Process: NSObject {
298298
guard url.isFileURL else { fatalError("non-file URL argument") }
299299
_currentDirectoryPath = url.path
300300
} else {
301-
_currentDirectoryPath = FileManager.default.currentDirectoryPath
301+
_currentDirectoryPath = FileManager.default.currentDirectoryURL
302302
}
303303
}
304304
}
@@ -663,7 +663,7 @@ open class Process: NSObject {
663663
CFSocketCreateRunLoopSource(kCFAllocatorDefault, socket, 0)
664664
CFRunLoopAddSource(managerThreadRunLoop?._cfRunLoop, source, kCFRunLoopDefaultMode)
665665

666-
let workingDirectory = currentDirectoryURL?.path ?? FileManager.default.currentDirectoryPath
666+
let workingDirectory = currentDirectoryURL?.path ?? FileManager.default.currentDirectoryURL
667667
try quoteWindowsCommandLine(command).withCString(encodedAs: UTF16.self) { wszCommandLine in
668668
try FileManager.default._fileSystemRepresentation(withPath: workingDirectory) { wszCurrentDirectory in
669669
try szEnvironment.withCString(encodedAs: UTF16.self) { wszEnvironment in
@@ -966,7 +966,7 @@ open class Process: NSObject {
966966
#endif
967967

968968
let fileManager = FileManager()
969-
let previousDirectoryPath = fileManager.currentDirectoryPath
969+
let previousDirectoryPath = fileManager.currentDirectoryURL
970970
if let dir = currentDirectoryURL?.path, !fileManager.changeCurrentDirectoryPath(dir) {
971971
throw _NSErrorWithErrno(errno, reading: true, url: currentDirectoryURL)
972972
}
@@ -1144,7 +1144,7 @@ open class Process: NSObject {
11441144
// convenience; create and launch
11451145
open class func launchedProcess(launchPath path: String, arguments: [String]) -> Process {
11461146
let process = Process()
1147-
process.launchPath = path
1147+
process.executableURL = path
11481148
process.arguments = arguments
11491149
process.launch()
11501150

Sources/FoundationNetworking/HTTPCookieStorage.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ open class HTTPCookieStorage: NSObject {
116116
}
117117
//if we were unable to create the desired directory, create the cookie file
118118
//in a subFolder (named after the bundle) of the `pwd`
119-
return FileManager.default.currentDirectoryPath + "/" + bundleName + fileName
119+
return FileManager.default.currentDirectoryURL + "/" + bundleName + fileName
120120
}
121121

122122
// `URLSessionConfiguration.ephemeral` needs an ephemeral cookie storage.

Tests/Foundation/Tests/TestFileManager.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class TestFileManager : XCTestCase {
112112

113113
func test_creatingDirectoryWithShortIntermediatePath() {
114114
let fileManager = FileManager.default
115-
let cwd = fileManager.currentDirectoryPath
115+
let cwd = fileManager.currentDirectoryURL
116116
fileManager.changeCurrentDirectoryPath(NSTemporaryDirectory())
117117

118118
let relativePath = NSUUID().uuidString
@@ -1600,7 +1600,7 @@ VIDEOS=StopgapVideos
16001600
XCTAssertEqual(fm.string(withFileSystemRepresentation: UnsafePointer(bitPattern: 1)!, length: 0), "")
16011601

16021602
XCTAssertFalse(fm.changeCurrentDirectoryPath(""))
1603-
XCTAssertNotEqual(fm.currentDirectoryPath, "")
1603+
XCTAssertNotEqual(fm.currentDirectoryURL, "")
16041604

16051605
// Not Implemented - XCTAssertNil(fm.componentsToDisplay(forPath: ""))
16061606
// Not Implemented - XCTAssertEqual(fm.displayName(atPath: ""), "")
@@ -1881,7 +1881,7 @@ VIDEOS=StopgapVideos
18811881
} catch {
18821882
XCTFail()
18831883
}
1884-
let originalWorkingDirectory = fm.currentDirectoryPath
1884+
let originalWorkingDirectory = fm.currentDirectoryURL
18851885
defer {
18861886
fm.changeCurrentDirectoryPath(originalWorkingDirectory)
18871887
}

Tests/Foundation/Tests/TestProcess.swift

+24-24
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class TestProcess : XCTestCase {
1616
process.executableURL = executableURL
1717
} else {
1818
// Fallback on earlier versions
19-
process.launchPath = executableURL.path
19+
process.executableURL = executableURL.path
2020
}
21-
XCTAssertEqual(executableURL.path, process.launchPath)
21+
XCTAssertEqual(executableURL.path, process.executableURL)
2222
process.arguments = ["--exit", "0"]
2323
try process.run()
2424
process.waitUntilExit()
@@ -123,7 +123,7 @@ class TestProcess : XCTestCase {
123123
return
124124
}
125125

126-
XCTAssertEqual(string.trimmingCharacters(in: CharacterSet(["\n", "\r"])), FileManager.default.currentDirectoryPath)
126+
XCTAssertEqual(string.trimmingCharacters(in: CharacterSet(["\n", "\r"])), FileManager.default.currentDirectoryURL)
127127
}
128128

129129
func test_pipe_stderr() throws {
@@ -208,7 +208,7 @@ class TestProcess : XCTestCase {
208208
XCTFail("Could not read stdout")
209209
return
210210
}
211-
XCTAssertEqual(string.trimmingCharacters(in: CharacterSet(["\r", "\n"])), FileManager.default.currentDirectoryPath)
211+
XCTAssertEqual(string.trimmingCharacters(in: CharacterSet(["\r", "\n"])), FileManager.default.currentDirectoryURL)
212212
}
213213

214214
func test_passthrough_environment() {
@@ -260,7 +260,7 @@ class TestProcess : XCTestCase {
260260
func test_current_working_directory() throws {
261261
let tmpDir = { () -> String in
262262
// NSTemporaryDirectory might return a final slash, but
263-
// FileManager.currentDirectoryPath seems to avoid it.
263+
// FileManager.currentDirectoryURL seems to avoid it.
264264
var dir = NSTemporaryDirectory()
265265
if (dir.hasSuffix("/") && dir != "/") || dir.hasSuffix("\\") {
266266
dir.removeLast()
@@ -269,7 +269,7 @@ class TestProcess : XCTestCase {
269269
}()
270270

271271
let fm = FileManager.default
272-
let previousWorkingDirectory = fm.currentDirectoryPath
272+
let previousWorkingDirectory = fm.currentDirectoryURL
273273
XCTAssertNotEqual(previousWorkingDirectory.standardizePath(), tmpDir)
274274

275275
// Test that getcwd() returns the currentDirectoryPath
@@ -285,7 +285,7 @@ class TestProcess : XCTestCase {
285285
do {
286286
let (pwd, _) = try runTask([xdgTestHelperURL().path, "--echo-PWD"], currentDirectoryPath: tmpDir)
287287
// Check the sub-process used the correct directory
288-
let cwd = FileManager.default.currentDirectoryPath.standardizePath()
288+
let cwd = FileManager.default.currentDirectoryURL.standardizePath()
289289
XCTAssertNotEqual(cwd, tmpDir)
290290
XCTAssertNotEqual(pwd.trimmingCharacters(in: .newlines).standardizePath(), tmpDir)
291291
} catch {
@@ -314,12 +314,12 @@ class TestProcess : XCTestCase {
314314
XCTFail("Test failed: \(error)")
315315
}
316316

317-
XCTAssertEqual(previousWorkingDirectory, fm.currentDirectoryPath)
317+
XCTAssertEqual(previousWorkingDirectory, fm.currentDirectoryURL)
318318
}
319319

320320
func test_run() {
321321
let fm = FileManager.default
322-
let cwd = fm.currentDirectoryPath
322+
let cwd = fm.currentDirectoryURL
323323

324324
do {
325325
let process = try Process.run(xdgTestHelperURL(), arguments: ["--exit", "123"], terminationHandler: nil)
@@ -329,7 +329,7 @@ class TestProcess : XCTestCase {
329329
} catch {
330330
XCTFail("Cant execute \(xdgTestHelperURL().path): \(error)")
331331
}
332-
XCTAssertEqual(fm.currentDirectoryPath, cwd)
332+
XCTAssertEqual(fm.currentDirectoryURL, cwd)
333333

334334
do {
335335
// Check running the process twice throws an error.
@@ -353,7 +353,7 @@ class TestProcess : XCTestCase {
353353
process.currentDirectoryURL = URL(fileURLWithPath: "/.../_no_such_directory", isDirectory: true)
354354
XCTAssertThrowsError(try process.run())
355355
}
356-
XCTAssertEqual(fm.currentDirectoryPath, cwd)
356+
XCTAssertEqual(fm.currentDirectoryURL, cwd)
357357

358358
do {
359359
let process = Process()
@@ -362,7 +362,7 @@ class TestProcess : XCTestCase {
362362
process.currentDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory())
363363
XCTAssertThrowsError(try process.run())
364364
}
365-
XCTAssertEqual(fm.currentDirectoryPath, cwd)
365+
XCTAssertEqual(fm.currentDirectoryURL, cwd)
366366
fm.changeCurrentDirectoryPath(cwd)
367367
}
368368

@@ -599,7 +599,7 @@ class TestProcess : XCTestCase {
599599
XCTAssertNotNil(process.currentDirectoryURL)
600600

601601
// Test currentDirectoryURL cannot be set to nil even though it is a URL?
602-
let cwd = URL(fileURLWithPath: FileManager.default.currentDirectoryPath, isDirectory: true)
602+
let cwd = URL(fileURLWithPath: FileManager.default.currentDirectoryURL, isDirectory: true)
603603
process.currentDirectoryURL = nil
604604
XCTAssertNotNil(process.currentDirectoryURL)
605605
XCTAssertEqual(process.currentDirectoryURL, cwd)
@@ -609,7 +609,7 @@ class TestProcess : XCTestCase {
609609
XCTAssertEqual(aFileURL.path, "/a_file")
610610
process.currentDirectoryURL = aFileURL
611611
XCTAssertNotEqual(process.currentDirectoryURL, aFileURL)
612-
XCTAssertEqual(process.currentDirectoryPath, "/a_file")
612+
XCTAssertEqual(process.currentDirectoryURL, "/a_file")
613613
XCTAssertTrue(try XCTUnwrap(process.currentDirectoryURL).hasDirectoryPath)
614614
XCTAssertEqual(try XCTUnwrap(process.currentDirectoryURL).absoluteString, "file:///a_file/")
615615

@@ -618,15 +618,15 @@ class TestProcess : XCTestCase {
618618
XCTAssertEqual(aDirURL.path, "/a_dir")
619619
process.currentDirectoryURL = aDirURL
620620
XCTAssertEqual(process.currentDirectoryURL, aDirURL)
621-
XCTAssertEqual(process.currentDirectoryPath, "/a_dir")
621+
XCTAssertEqual(process.currentDirectoryURL, "/a_dir")
622622
XCTAssertTrue(try XCTUnwrap(process.currentDirectoryURL).hasDirectoryPath)
623623
XCTAssertEqual(try XCTUnwrap(process.currentDirectoryURL).absoluteString, "file:///a_dir/")
624624

625-
process.currentDirectoryPath = ""
626-
XCTAssertEqual(process.currentDirectoryPath, "")
625+
process.currentDirectoryURL = ""
626+
XCTAssertEqual(process.currentDirectoryURL, "")
627627
XCTAssertNil(process.currentDirectoryURL)
628628
process.currentDirectoryURL = nil
629-
XCTAssertEqual(process.currentDirectoryPath, cwd.path)
629+
XCTAssertEqual(process.currentDirectoryURL, cwd.path)
630630

631631

632632
process.executableURL = URL(fileURLWithPath: "/some_file_that_doesnt_exist", isDirectory: false)
@@ -654,8 +654,8 @@ class TestProcess : XCTestCase {
654654
// The closed thing is %CD% which is a property of the shell rather
655655
// than the environment. Simply ignore this test on Windows.
656656
#if !os(Windows)
657-
XCTAssertNotEqual("/", FileManager.default.currentDirectoryPath)
658-
XCTAssertNotEqual(FileManager.default.currentDirectoryPath, "/")
657+
XCTAssertNotEqual("/", FileManager.default.currentDirectoryURL)
658+
XCTAssertNotEqual(FileManager.default.currentDirectoryURL, "/")
659659
let (stdout, _) = try runTask([xdgTestHelperURL().path, "--echo-PWD"], currentDirectoryPath: "/")
660660
let directory = stdout.trimmingCharacters(in: CharacterSet(["\n", "\r"]))
661661
XCTAssertEqual(directory, ProcessInfo.processInfo.environment["PWD"])
@@ -667,7 +667,7 @@ class TestProcess : XCTestCase {
667667
let process = Process()
668668
process.executableURL = xdgTestHelperURL()
669669
process.arguments = [ "--getcwd" ]
670-
process.currentDirectoryPath = ""
670+
process.currentDirectoryURL = ""
671671

672672
let stdoutPipe = Pipe()
673673
process.standardOutput = stdoutPipe
@@ -688,7 +688,7 @@ class TestProcess : XCTestCase {
688688
throw Error.UnicodeDecodingError(stdoutData)
689689
}
690690
let directory = stdout.trimmingCharacters(in: CharacterSet(["\n", "\r"]))
691-
XCTAssertEqual(directory, FileManager.default.currentDirectoryPath)
691+
XCTAssertEqual(directory, FileManager.default.currentDirectoryURL)
692692
} catch {
693693
XCTFail(String(describing: error))
694694
}
@@ -800,7 +800,7 @@ class TestProcess : XCTestCase {
800800
do {
801801
let data = try XCTUnwrap(pipe3.fileHandleForReading.readToEnd())
802802
let pwd = String.init(decoding: data, as: UTF8.self).trimmingCharacters(in: CharacterSet(["\n", "\r"]))
803-
XCTAssertEqual(pwd, FileManager.default.currentDirectoryPath.standardizePath())
803+
XCTAssertEqual(pwd, FileManager.default.currentDirectoryURL.standardizePath())
804804
} catch {
805805
XCTFail("\(error)")
806806
}
@@ -971,7 +971,7 @@ internal func runTask(_ arguments: [String], environment: [String: String]? = ni
971971
let process = Process()
972972

973973
var arguments = arguments
974-
process.launchPath = arguments.removeFirst()
974+
process.executableURL = arguments.removeFirst()
975975
process.arguments = arguments
976976
// Darwin Foundation doesnt allow .environment to be set to nil although the documentation
977977
// says it is an optional. https://developer.apple.com/documentation/foundation/process/1409412-environment

Tests/Foundation/Tests/TestURL.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class TestURL : XCTestCase {
328328

329329
static let gBaseTemporaryDirectoryPath = (NSTemporaryDirectory() as NSString).appendingPathComponent("org.swift.foundation.TestFoundation.TestURL.\(ProcessInfo.processInfo.processIdentifier)")
330330
static var gBaseCurrentWorkingDirectoryPath : String {
331-
return FileManager.default.currentDirectoryPath
331+
return FileManager.default.currentDirectoryURL
332332
}
333333
static var gSavedPath = ""
334334
static var gRelativeOffsetFromBaseCurrentWorkingDirectory: UInt = 0
@@ -384,10 +384,10 @@ class TestURL : XCTestCase {
384384
}
385385
}
386386

387-
TestURL.gSavedPath = FileManager.default.currentDirectoryPath
387+
TestURL.gSavedPath = FileManager.default.currentDirectoryURL
388388
FileManager.default.changeCurrentDirectoryPath(NSTemporaryDirectory())
389389

390-
let cwd = FileManager.default.currentDirectoryPath
390+
let cwd = FileManager.default.currentDirectoryURL
391391
let cwdURL = URL(fileURLWithPath: cwd, isDirectory: true)
392392
// 1 for path separator
393393
cwdURL.withUnsafeFileSystemRepresentation {
@@ -545,7 +545,7 @@ class TestURL : XCTestCase {
545545
try fileManager.createDirectory(at: writableTestDirectoryURL, withIntermediateDirectories: true)
546546
defer { try? fileManager.removeItem(at: writableTestDirectoryURL) }
547547

548-
let previousCurrentDirectory = fileManager.currentDirectoryPath
548+
let previousCurrentDirectory = fileManager.currentDirectoryURL
549549
fileManager.changeCurrentDirectoryPath(writableTestDirectoryURL.path)
550550
defer { fileManager.changeCurrentDirectoryPath(previousCurrentDirectory) }
551551

Tests/Tools/GenerateTestFixtures/main.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
let arguments = ProcessInfo.processInfo.arguments
5454
let outputRoot: URL
5555
if arguments.count > 1 {
56-
outputRoot = URL(fileURLWithPath: arguments[1], relativeTo: URL(fileURLWithPath: FileManager.default.currentDirectoryPath))
56+
outputRoot = URL(fileURLWithPath: arguments[1], relativeTo: URL(fileURLWithPath: FileManager.default.currentDirectoryURL))
5757
} else {
5858
outputRoot = Bundle.main.executableURL!.deletingLastPathComponent()
5959
}

Tests/Tools/XDGTestHelper/main.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ case "--xdgcheck":
226226
XDGCheck.run()
227227

228228
case "--getcwd":
229-
print(FileManager.default.currentDirectoryPath)
229+
print(FileManager.default.currentDirectoryURL)
230230

231231
case "--echo-PWD":
232232
print(ProcessInfo.processInfo.environment["PWD"] ?? "")

0 commit comments

Comments
 (0)