Skip to content

Commit ee4cb5e

Browse files
authored
mark several FileSystem APIs as disfavored overloads (#418)
motivation: help the transition off of TSC Path and FileSystem changes: * mark several FileSystem APIs that return AbsolutePath as disfavored overloads * deprecate Product which is really a SwiftPM construct
1 parent 78e53cb commit ee4cb5e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Sources/TSCBasic/FileSystem.swift

+8
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public enum FileMode: Sendable {
148148
/// - Note: All of these APIs are synchronous and can block.
149149
public protocol FileSystem: Sendable {
150150
/// Check whether the given path exists and is accessible.
151+
@_disfavoredOverload
151152
func exists(_ path: AbsolutePath, followSymlink: Bool) -> Bool
152153

153154
/// Check whether the given path is accessible and a directory.
@@ -183,6 +184,7 @@ public protocol FileSystem: Sendable {
183184
/// The current working directory can be empty if e.g. the directory became
184185
/// unavailable while the current process was still working in it.
185186
/// This follows the POSIX `getcwd(3)` semantics.
187+
@_disfavoredOverload
186188
var currentWorkingDirectory: AbsolutePath? { get }
187189

188190
/// Change the current working directory.
@@ -191,12 +193,15 @@ public protocol FileSystem: Sendable {
191193
func changeCurrentWorkingDirectory(to path: AbsolutePath) throws
192194

193195
/// Get the home directory of current user
196+
@_disfavoredOverload
194197
var homeDirectory: AbsolutePath { get throws }
195198

196199
/// Get the caches directory of current user
200+
@_disfavoredOverload
197201
var cachesDirectory: AbsolutePath? { get }
198202

199203
/// Get the temp directory
204+
@_disfavoredOverload
200205
var tempDirectory: AbsolutePath { get throws }
201206

202207
/// Create the given directory.
@@ -259,6 +264,7 @@ public protocol FileSystem: Sendable {
259264
/// methods).
260265
public extension FileSystem {
261266
/// exists override with default value.
267+
@_disfavoredOverload
262268
func exists(_ path: AbsolutePath) -> Bool {
263269
return exists(path, followSymlink: true)
264270
}
@@ -275,6 +281,7 @@ public extension FileSystem {
275281

276282
// Unless the file system type provides an override for this method, throw
277283
// if `atomically` is `true`, otherwise fall back to whatever implementation already exists.
284+
@_disfavoredOverload
278285
func writeFileContents(_ path: AbsolutePath, bytes: ByteString, atomically: Bool) throws {
279286
guard !atomically else {
280287
throw FileSystemError(.unsupported, path)
@@ -283,6 +290,7 @@ public extension FileSystem {
283290
}
284291

285292
/// Write to a file from a stream producer.
293+
@_disfavoredOverload
286294
func writeFileContents(_ path: AbsolutePath, body: (WritableByteStream) -> Void) throws {
287295
let contents = BufferedOutputByteStream()
288296
body(contents)

Sources/TSCTestSupport/Product.swift

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import TSCUtility
1818
import class Foundation.Bundle
1919
#endif
2020

21+
@available(*, deprecated, message: "moved to SwiftPM")
2122
public enum SwiftPMProductError: Swift.Error {
2223
case packagePathNotFound
2324
case executionFailure(error: Swift.Error, output: String, stderr: String)
@@ -26,10 +27,12 @@ public enum SwiftPMProductError: Swift.Error {
2627
/// Defines the executables used by SwiftPM.
2728
/// Contains path to the currently built executable and
2829
/// helper method to execute them.
30+
@available(*, deprecated, message: "moved to SwiftPM")
2931
public protocol Product {
3032
var exec: RelativePath { get }
3133
}
3234

35+
@available(*, deprecated, message: "moved to SwiftPM")
3336
extension Product {
3437
/// Path to currently built binary.
3538
public var path: AbsolutePath {

0 commit comments

Comments
 (0)