@@ -19,25 +19,35 @@ public struct Path {
19
19
public static let separator = " / "
20
20
21
21
/// The underlying string representation
22
- internal var path : String
22
+ internal let path : String
23
23
24
- internal static var fileManager = FileManager . default
24
+ internal static let fileManager = FileManager . default
25
25
26
- internal var fileSystemInfo : FileSystemInfo = DefaultFileSystemInfo ( )
26
+ internal let fileSystemInfo : FileSystemInfo
27
27
28
28
// MARK: Init
29
29
30
30
public init ( ) {
31
- self . path = " "
31
+ self . init ( " " )
32
32
}
33
33
34
34
/// Create a Path from a given String
35
35
public init ( _ path: String ) {
36
+ self . init ( path, fileSystemInfo: DefaultFileSystemInfo ( ) )
37
+ }
38
+
39
+ internal init ( _ path: String , fileSystemInfo: FileSystemInfo ) {
36
40
self . path = path
41
+ self . fileSystemInfo = fileSystemInfo
37
42
}
38
43
44
+ internal init ( fileSystemInfo: FileSystemInfo ) {
45
+ self . init ( " " , fileSystemInfo: fileSystemInfo)
46
+ }
47
+
39
48
/// Create a Path by joining multiple path components together
40
49
public init < S : Collection > ( components: S ) where S. Iterator. Element == String {
50
+ let path : String
41
51
if components. isEmpty {
42
52
path = " . "
43
53
} else if components. first == Path . separator && components. count > 1 {
@@ -46,6 +56,7 @@ public struct Path {
46
56
} else {
47
57
path = components. joined ( separator: Path . separator)
48
58
}
59
+ self . init ( path)
49
60
}
50
61
}
51
62
@@ -65,7 +76,7 @@ extension Path : ExpressibleByStringLiteral {
65
76
}
66
77
67
78
public init ( stringLiteral value: StringLiteralType ) {
68
- self . path = value
79
+ self . init ( value)
69
80
}
70
81
}
71
82
0 commit comments