Skip to content

Commit dbe9b6a

Browse files
committed
refactor AbsolutePath based on URL and RelativePath based on [String]
motivation: better support for Windows style paths changes: * refactor AbsolutePath based on URL * refactor RelativePath based on [String] * remove redundant API surface area from RelativePath (anything not used outside tests) * remove RelativePath tests that covered redundant APIs
1 parent 85d19a9 commit dbe9b6a

File tree

16 files changed

+369
-156
lines changed

16 files changed

+369
-156
lines changed

Sources/Basics/Archiver/TarArchiver.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public struct TarArchiver: Archiver {
5151
) {
5252
do {
5353
guard self.fileSystem.exists(archivePath) else {
54-
throw FileSystemError(.noEntry, archivePath.underlying)
54+
throw FileSystemError(.noEntry, .init(archivePath.pathString))
5555
}
5656

5757
guard self.fileSystem.isDirectory(destinationPath) else {
58-
throw FileSystemError(.notDirectory, destinationPath.underlying)
58+
throw FileSystemError(.notDirectory, .init(destinationPath.pathString))
5959
}
6060

6161
let process = TSCBasic.Process(
@@ -88,12 +88,12 @@ public struct TarArchiver: Archiver {
8888
) {
8989
do {
9090
guard self.fileSystem.isDirectory(directory) else {
91-
throw FileSystemError(.notDirectory, directory.underlying)
91+
throw FileSystemError(.notDirectory, .init(directory.pathString))
9292
}
9393

9494
let process = TSCBasic.Process(
9595
arguments: [self.tarCommand, "acf", destinationPath.pathString, directory.basename],
96-
workingDirectory: directory.parentDirectory.underlying
96+
workingDirectory: .init(directory.parentDirectory.pathString)
9797
)
9898

9999
guard let registrationKey = self.cancellator.register(process) else {
@@ -118,7 +118,7 @@ public struct TarArchiver: Archiver {
118118
public func validate(path: AbsolutePath, completion: @escaping (Result<Bool, Error>) -> Void) {
119119
do {
120120
guard self.fileSystem.exists(path) else {
121-
throw FileSystemError(.noEntry, path.underlying)
121+
throw FileSystemError(.noEntry, .init(path.pathString))
122122
}
123123

124124
let process = TSCBasic.Process(arguments: [self.tarCommand, "tf", path.pathString])

Sources/Basics/Archiver/ZipArchiver.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public struct ZipArchiver: Archiver, Cancellable {
4141
) {
4242
do {
4343
guard self.fileSystem.exists(archivePath) else {
44-
throw FileSystemError(.noEntry, archivePath.underlying)
44+
throw FileSystemError(.noEntry, .init(archivePath.pathString))
4545
}
4646

4747
guard self.fileSystem.isDirectory(destinationPath) else {
48-
throw FileSystemError(.notDirectory, destinationPath.underlying)
48+
throw FileSystemError(.notDirectory, .init(destinationPath))
4949
}
5050

5151
#if os(Windows)
@@ -81,7 +81,7 @@ public struct ZipArchiver: Archiver, Cancellable {
8181
) {
8282
do {
8383
guard self.fileSystem.isDirectory(directory) else {
84-
throw FileSystemError(.notDirectory, directory.underlying)
84+
throw FileSystemError(.notDirectory, .init(directory.pathString))
8585
}
8686

8787
#if os(Windows)
@@ -93,7 +93,7 @@ public struct ZipArchiver: Archiver, Cancellable {
9393
#else
9494
let process = TSCBasic.Process(
9595
arguments: ["zip", "-r", destinationPath.pathString, directory.basename],
96-
workingDirectory: directory.parentDirectory.underlying
96+
workingDirectory: .init(directory.parentDirectory.pathString)
9797
)
9898
#endif
9999

@@ -119,7 +119,7 @@ public struct ZipArchiver: Archiver, Cancellable {
119119
public func validate(path: AbsolutePath, completion: @escaping (Result<Bool, Error>) -> Void) {
120120
do {
121121
guard self.fileSystem.exists(path) else {
122-
throw FileSystemError(.noEntry, path.underlying)
122+
throw FileSystemError(.noEntry, .init(path.pathString))
123123
}
124124

125125
#if os(Windows)

0 commit comments

Comments
 (0)