Skip to content

Commit 0914671

Browse files
committed
deprecated createSymlink in PathShims
1 parent eab6ec3 commit 0914671

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

Sources/TSCBasic/PathShims.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public func makeDirectories(_ path: AbsolutePath) throws {
6161

6262
/// Creates a symbolic link at `path` whose content points to `dest`. If `relative` is true, the symlink contents will
6363
/// be a relative path, otherwise it will be absolute.
64+
@available(*, deprecated, renamed: "localFileSystem.createSymbolicLink")
6465
public func createSymlink(_ path: AbsolutePath, pointingAt dest: AbsolutePath, relative: Bool = true) throws {
6566
let destString = relative ? dest.relative(to: path.parentDirectory).pathString : dest.pathString
6667
try FileManager.default.createSymbolicLink(atPath: path.pathString, withDestinationPath: destString)

Tests/TSCBasicTests/FileSystemTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class FileSystemTests: XCTestCase {
3737

3838
// isSymlink()
3939
let sym = tempDirPath.appending(component: "hello")
40-
try! createSymlink(sym, pointingAt: file.path)
40+
try! fs.createSymbolicLink(sym, pointingAt: file.path)
4141
XCTAssertTrue(fs.isSymlink(sym))
4242
XCTAssertTrue(fs.isFile(sym))
4343
XCTAssertEqual(try fs.getFileInfo(sym).fileType, .typeSymbolicLink)
@@ -46,15 +46,15 @@ class FileSystemTests: XCTestCase {
4646
// isExecutableFile
4747
let executable = tempDirPath.appending(component: "exec-foo")
4848
let executableSym = tempDirPath.appending(component: "exec-sym")
49-
try! createSymlink(executableSym, pointingAt: executable)
49+
try! fs.createSymbolicLink(executableSym, pointingAt: executable)
5050
let stream = BufferedOutputByteStream()
5151
stream <<< """
5252
#!/bin/sh
5353
set -e
5454
exit
5555
5656
"""
57-
try! localFileSystem.writeFileContents(executable, bytes: stream.bytes)
57+
try! fs.writeFileContents(executable, bytes: stream.bytes)
5858
try! Process.checkNonZeroExit(args: "chmod", "+x", executable.pathString)
5959
XCTAssertTrue(fs.isExecutableFile(executable))
6060
XCTAssertTrue(fs.isExecutableFile(executableSym))
@@ -94,7 +94,7 @@ class FileSystemTests: XCTestCase {
9494

9595
// Source and target exist.
9696

97-
try createSymlink(source, pointingAt: target)
97+
try fs.createSymbolicLink(source, pointingAt: target)
9898
XCTAssertEqual(fs.exists(source), true)
9999
XCTAssertEqual(fs.exists(source, followSymlink: true), true)
100100
XCTAssertEqual(fs.exists(source, followSymlink: false), true)
@@ -563,7 +563,7 @@ class FileSystemTests: XCTestCase {
563563
try fs.createDirectory(dir, recursive: true)
564564
try fs.writeFileContents(foo, bytes: "")
565565
try fs.writeFileContents(bar, bytes: "")
566-
try createSymlink(sym, pointingAt: foo)
566+
try fs.createSymbolicLink(sym, pointingAt: foo)
567567

568568
// Set foo to unwritable.
569569
try fs.chmod(.userUnWritable, path: foo)

Tests/TSCBasicTests/POSIXTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ class POSIXTests : XCTestCase {
2626
XCTAssertTrue(localFileSystem.isDirectory(dirPath))
2727

2828
let sym = dirPath.appending(component: "hello")
29-
try createSymlink(sym, pointingAt: file.path)
29+
try localFileSystem.createSymbolicLink(sym, pointingAt: file.path)
3030
XCTAssertTrue(localFileSystem.exists(sym))
3131
XCTAssertTrue(localFileSystem.isFile(sym))
3232
XCTAssertFalse(localFileSystem.isDirectory(sym))
3333

3434
try withTemporaryDirectory(removeTreeOnDeinit: true) { dir2Path in
3535
let dirSym = dirPath.appending(component: "dir2")
36-
try createSymlink(dirSym, pointingAt: dir2Path)
36+
try localFileSystem.createSymbolicLink(dirSym, pointingAt: dir2Path)
3737
XCTAssertTrue(localFileSystem.exists(dirSym))
3838
XCTAssertFalse(localFileSystem.isFile(dirSym))
3939
XCTAssertTrue(localFileSystem.isDirectory(dirSym))

Tests/TSCBasicTests/PathShimTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class PathShimTests : XCTestCase {
2929
let fldrPath = tmpDirPath.appending(component: "fldr")
3030

3131
// Create a symbolic link pointing at the (so far non-existent) directory.
32-
try! createSymlink(slnkPath, pointingAt: fldrPath, relative: true)
32+
try! localFileSystem.createSymbolicLink(slnkPath, pointingAt: fldrPath)
3333

3434
// Resolving the symlink should not yet change anything.
3535
XCTAssertEqual(resolveSymlinks(slnkPath), slnkPath)
@@ -113,7 +113,7 @@ class WalkTests : XCTestCase {
113113

114114
try! makeDirectories(tmpDirPath.appending(component: "foo"))
115115
try! makeDirectories(tmpDirPath.appending(components: "bar", "baz", "goo"))
116-
try! createSymlink(tmpDirPath.appending(components: "foo", "symlink"), pointingAt: tmpDirPath.appending(component: "bar"), relative: true)
116+
try! localFileSystem.createSymbolicLink(tmpDirPath.appending(components: "foo", "symlink"), pointingAt: tmpDirPath.appending(component: "bar"))
117117

118118
XCTAssertTrue(localFileSystem.isSymlink(tmpDirPath.appending(components: "foo", "symlink")))
119119
XCTAssertEqual(resolveSymlinks(tmpDirPath.appending(components: "foo", "symlink")), tmpDirPath.appending(component: "bar"))
@@ -129,8 +129,8 @@ class WalkTests : XCTestCase {
129129
try! withTemporaryDirectory(removeTreeOnDeinit: true) { tmpDirPath in
130130
try! makeDirectories(tmpDirPath.appending(components: "foo", "bar"))
131131
try! makeDirectories(tmpDirPath.appending(components: "abc", "bar"))
132-
try! createSymlink(tmpDirPath.appending(component: "symlink"), pointingAt: tmpDirPath.appending(component: "foo"), relative: true)
133-
try! createSymlink(tmpDirPath.appending(components: "foo", "baz"), pointingAt: tmpDirPath.appending(component: "abc"), relative: true)
132+
try! localFileSystem.createSymbolicLink(tmpDirPath.appending(component: "symlink"), pointingAt: tmpDirPath.appending(component: "foo"))
133+
try! localFileSystem.createSymbolicLink(tmpDirPath.appending(components: "foo", "baz"), pointingAt: tmpDirPath.appending(component: "abc"))
134134

135135
XCTAssertTrue(localFileSystem.isSymlink(tmpDirPath.appending(component: "symlink")))
136136

0 commit comments

Comments
 (0)