Skip to content

Commit d7ec183

Browse files
committed
Reimplement Path API with SwiftSystem
1 parent fc5b8a5 commit d7ec183

File tree

8 files changed

+304
-803
lines changed

8 files changed

+304
-803
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2323

2424
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
2525

26+
if(FIND_PM_DEPS)
27+
find_package(SwiftSystem CONFIG REQUIRED)
28+
endif()
29+
2630
find_package(dispatch QUIET)
2731
find_package(Foundation QUIET)
2832
find_package(Threads QUIET)

Package.resolved

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ let package = Package(
2828
name: "TSCTestSupport",
2929
targets: ["TSCTestSupport"]),
3030
],
31-
dependencies: [],
31+
dependencies: [
32+
.package(url: "https://github.com/apple/swift-system.git", .upToNextMinor(from: "0.0.1"))
33+
],
3234
targets: [
3335

3436
// MARK: Tools support core targets
@@ -44,7 +46,8 @@ let package = Package(
4446
.target(
4547
/** TSCBasic support library */
4648
name: "TSCBasic",
47-
dependencies: ["TSCLibc", "TSCclibc"]),
49+
dependencies: ["TSCLibc", "TSCclibc",
50+
.product(name: "SystemPackage", package: "swift-system")]),
4851
.target(
4952
/** Abstractions for common operations, should migrate to TSCBasic */
5053
name: "TSCUtility",

Sources/TSCBasic/FileSystem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ private class LocalFileSystem: FileSystem {
377377
}
378378

379379
func createSymbolicLink(_ path: AbsolutePath, pointingAt destination: AbsolutePath, relative: Bool) throws {
380-
let destString = relative ? destination.relative(to: path.parentDirectory).pathString : destination.pathString
380+
let destString = relative ? try destination.relative(to: path.parentDirectory).pathString : destination.pathString
381381
try FileManager.default.createSymbolicLink(atPath: path.pathString, withDestinationPath: destString)
382382
}
383383

@@ -803,7 +803,7 @@ public class InMemoryFileSystem: FileSystem {
803803
throw FileSystemError(.alreadyExistsAtDestination, path)
804804
}
805805

806-
let destination = relative ? destination.relative(to: path.parentDirectory).pathString : destination.pathString
806+
let destination = relative ? try destination.relative(to: path.parentDirectory).pathString : destination.pathString
807807

808808
contents.entries[path.basename] = Node(.symlink(destination))
809809
}

0 commit comments

Comments
 (0)