Skip to content

TSCBasic: make LocalFileSystem a struct #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Sources/TSCBasic/FileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public enum FileMode: Sendable {
/// substitute a virtual file system or redirect file system operations.
///
/// - Note: All of these APIs are synchronous and can block.
public protocol FileSystem: AnyObject, Sendable {
public protocol FileSystem: Sendable {
/// Check whether the given path exists and is accessible.
func exists(_ path: AbsolutePath, followSymlink: Bool) -> Bool

Expand Down Expand Up @@ -296,7 +296,7 @@ public extension FileSystem {
}

/// Concrete FileSystem implementation which communicates with the local file system.
private final class LocalFileSystem: FileSystem {
private struct LocalFileSystem: FileSystem {
func isExecutableFile(_ path: AbsolutePath) -> Bool {
// Our semantics doesn't consider directories.
return (self.isFile(path) || self.isSymlink(path)) && FileManager.default.isExecutableFile(atPath: path.pathString)
Expand Down Expand Up @@ -1176,9 +1176,6 @@ public var localFileSystem: FileSystem {
}
}

// `LocalFileSystem` doesn't hold any internal state and all of its underlying operations are blocking.
extension LocalFileSystem: @unchecked Sendable {}

extension FileSystem {
/// Print the filesystem tree of the given path.
///
Expand Down