1111import TSCLibc
1212import Foundation
1313import Dispatch
14+ import SystemPackage
1415
1516public struct FileSystemError : Error , Equatable {
1617 public enum Kind : Equatable {
@@ -175,7 +176,7 @@ public protocol FileSystem: AnyObject {
175176
176177 /// Get the home directory of current user
177178 var homeDirectory : AbsolutePath { get }
178-
179+
179180 /// Get the caches directory of current user
180181 var cachesDirectory : AbsolutePath ? { get }
181182
@@ -346,7 +347,7 @@ private class LocalFileSystem: FileSystem {
346347 var homeDirectory : AbsolutePath {
347348 return AbsolutePath ( NSHomeDirectory ( ) )
348349 }
349-
350+
350351 var cachesDirectory : AbsolutePath ? {
351352 return FileManager . default. urls ( for: . cachesDirectory, in: . userDomainMask) . first. flatMap { AbsolutePath ( $0. path) }
352353 }
@@ -515,7 +516,7 @@ private class LocalFileSystem: FileSystem {
515516//
516517/// Concrete FileSystem implementation which simulates an empty disk.
517518public class InMemoryFileSystem : FileSystem {
518-
519+
519520 /// Private internal representation of a file system node.
520521 /// Not threadsafe.
521522 private class Node {
@@ -551,7 +552,7 @@ public class InMemoryFileSystem: FileSystem {
551552 }
552553 }
553554 }
554-
555+
555556 /// Private internal representation the contents of a directory.
556557 /// Not threadsafe.
557558 private class DirectoryContents {
@@ -573,7 +574,7 @@ public class InMemoryFileSystem: FileSystem {
573574
574575 /// The root node of the filesytem.
575576 private var root : Node
576-
577+
577578 /// Protects `root` and everything underneath it.
578579 /// FIXME: Using a single lock for this is a performance problem, but in
579580 /// reality, the only practical use for InMemoryFileSystem is for unit
@@ -583,7 +584,7 @@ public class InMemoryFileSystem: FileSystem {
583584 private var lockFiles = Dictionary < AbsolutePath , WeakReference < DispatchQueue > > ( )
584585 /// Used to access lockFiles in a thread safe manner.
585586 private let lockFilesLock = Lock ( )
586-
587+
587588 /// Exclusive file system lock vended to clients through `withLock()`.
588589 // Used to ensure that DispatchQueues are releassed when they are no longer in use.
589590 private struct WeakReference < Value: AnyObject > {
@@ -717,7 +718,7 @@ public class InMemoryFileSystem: FileSystem {
717718 // FIXME: Maybe we should allow setting this when creating the fs.
718719 return AbsolutePath ( " /home/user " )
719720 }
720-
721+
721722 public var cachesDirectory : AbsolutePath ? {
722723 return self . homeDirectory. appending ( component: " caches " )
723724 }
@@ -735,7 +736,7 @@ public class InMemoryFileSystem: FileSystem {
735736 return [ String] ( contents. entries. keys)
736737 }
737738 }
738-
739+
739740 /// Not threadsafe.
740741 private func _createDirectory( _ path: AbsolutePath , recursive: Bool ) throws {
741742 // Ignore if client passes root.
@@ -882,7 +883,7 @@ public class InMemoryFileSystem: FileSystem {
882883 public func chmod( _ mode: FileMode , path: AbsolutePath , options: Set < FileMode . Option > ) throws {
883884 // FIXME: We don't have these semantics in InMemoryFileSystem.
884885 }
885-
886+
886887 /// Private implementation of core copying function.
887888 /// Not threadsafe.
888889 private func _copy( from sourcePath: AbsolutePath , to destinationPath: AbsolutePath ) throws {
@@ -1023,7 +1024,7 @@ public class RerootedFileSystemView: FileSystem {
10231024 public var homeDirectory : AbsolutePath {
10241025 fatalError ( " homeDirectory on RerootedFileSystemView is not supported. " )
10251026 }
1026-
1027+
10271028 public var cachesDirectory : AbsolutePath ? {
10281029 fatalError ( " cachesDirectory on RerootedFileSystemView is not supported. " )
10291030 }
0 commit comments