@@ -30,9 +30,9 @@ extension FilePath {
30
30
/// * `\\?\Volume{12345678-abcd-1111-2222-123445789abc}\`
31
31
public struct Root {
32
32
internal var _path : FilePath
33
- internal var _rootEnd : SystemString . Index
33
+ internal var _rootEnd : _SystemString . Index
34
34
35
- internal init ( _ path: FilePath , rootEnd: SystemString . Index ) {
35
+ internal init ( _ path: FilePath , rootEnd: _SystemString . Index ) {
36
36
self . _path = path
37
37
self . _rootEnd = rootEnd
38
38
_invariantCheck ( )
@@ -56,14 +56,14 @@ extension FilePath {
56
56
/// path.append(file) // path is "/tmp/foo.txt"
57
57
public struct Component {
58
58
internal var _path : FilePath
59
- internal var _range : Range < SystemString . Index >
59
+ public var _range : Range < _SystemString . Index >
60
60
61
61
// TODO: Make a small-component form to save on ARC overhead when
62
62
// extracted from a path, and especially to save on allocation overhead
63
63
// when constructing one from a String literal.
64
64
65
65
internal init < RE: RangeExpression > ( _ path: FilePath , _ range: RE )
66
- where RE. Bound == SystemString . Index {
66
+ where RE. Bound == _SystemString . Index {
67
67
self . _path = path
68
68
self . _range = range. relative ( to: path. _storage)
69
69
precondition ( !self . _range. isEmpty, " FilePath components cannot be empty " )
@@ -104,7 +104,7 @@ extension FilePath.Root {
104
104
105
105
// MARK: - Internals
106
106
107
- extension SystemString {
107
+ extension _SystemString {
108
108
// TODO: take insertLeadingSlash: Bool
109
109
// TODO: turn into an insert operation with slide
110
110
internal mutating func appendComponents< C: Collection > (
@@ -127,21 +127,21 @@ extension SystemString {
127
127
128
128
// Unifying protocol for common functionality between roots, components,
129
129
// and views onto SystemString and FilePath.
130
- internal protocol _StrSlice : _PlatformStringable , Hashable , Codable {
131
- var _storage : SystemString { get }
132
- var _range : Range < SystemString . Index > { get }
130
+ public protocol _StrSlice : _PlatformStringable , Hashable , Codable {
131
+ var _storage : _SystemString { get }
132
+ var _range : Range < _SystemString . Index > { get }
133
133
134
- init ? ( _ str: SystemString )
134
+ init ? ( _ str: _SystemString )
135
135
136
136
func _invariantCheck( )
137
137
}
138
138
extension _StrSlice {
139
- internal var _slice : Slice < SystemString > {
139
+ internal var _slice : Slice < _SystemString > {
140
140
Slice ( base: _storage, bounds: _range)
141
141
}
142
142
143
143
internal func _withSystemChars< T> (
144
- _ f: ( UnsafeBufferPointer < SystemChar > ) throws -> T
144
+ _ f: ( UnsafeBufferPointer < _SystemChar > ) throws -> T
145
145
) rethrows -> T {
146
146
try _storage. withSystemChars {
147
147
try f ( UnsafeBufferPointer ( rebasing: $0 [ _range] ) )
@@ -153,17 +153,17 @@ extension _StrSlice {
153
153
try _slice. withCodeUnits ( f)
154
154
}
155
155
156
- internal init ? ( _platformString s: UnsafePointer < CInterop . PlatformChar > ) {
157
- self . init ( SystemString ( platformString: s) )
156
+ public init ? ( _platformString s: UnsafePointer < CInterop . PlatformChar > ) {
157
+ self . init ( _SystemString ( platformString: s) )
158
158
}
159
159
160
- internal func _withPlatformString< Result> (
160
+ public func _withPlatformString< Result> (
161
161
_ body: ( UnsafePointer < CInterop . PlatformChar > ) throws -> Result
162
162
) rethrows -> Result {
163
163
try _slice. withPlatformString ( body)
164
164
}
165
165
166
- internal var _systemString : SystemString { SystemString ( _slice) }
166
+ internal var _systemString : _SystemString { _SystemString ( _slice) }
167
167
}
168
168
extension _StrSlice {
169
169
public static func == ( lhs: Self , rhs: Self ) -> Bool {
@@ -180,35 +180,35 @@ internal protocol _PathSlice: _StrSlice {
180
180
var _path : FilePath { get }
181
181
}
182
182
extension _PathSlice {
183
- internal var _storage : SystemString { _path. _storage }
183
+ public var _storage : _SystemString { _path. _storage }
184
184
}
185
185
186
186
@available ( /*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8 , * )
187
187
extension FilePath . Component : _PathSlice {
188
188
}
189
189
@available ( /*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8 , * )
190
190
extension FilePath . Root : _PathSlice {
191
- internal var _range : Range < SystemString . Index > {
191
+ public var _range : Range < _SystemString . Index > {
192
192
( ..< _rootEnd) . relative ( to: _path. _storage)
193
193
}
194
194
}
195
195
196
196
@available ( /*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8 , * )
197
197
extension FilePath : _PlatformStringable {
198
- func _withPlatformString< Result> ( _ body: ( UnsafePointer < CInterop . PlatformChar > ) throws -> Result ) rethrows -> Result {
198
+ public func _withPlatformString< Result> ( _ body: ( UnsafePointer < CInterop . PlatformChar > ) throws -> Result ) rethrows -> Result {
199
199
try _storage. withPlatformString ( body)
200
200
}
201
201
202
- init ( _platformString: UnsafePointer < CInterop . PlatformChar > ) {
203
- self . init ( SystemString ( platformString: _platformString) )
202
+ public init ( _platformString: UnsafePointer < CInterop . PlatformChar > ) {
203
+ self . init ( _SystemString ( platformString: _platformString) )
204
204
}
205
205
206
206
}
207
207
208
208
@available ( /*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8 , * )
209
209
extension FilePath . Component {
210
210
// The index of the `.` denoting an extension
211
- internal func _extensionIndex( ) -> SystemString . Index ? {
211
+ internal func _extensionIndex( ) -> _SystemString . Index ? {
212
212
guard kind == . regular,
213
213
let idx = _slice. lastIndex ( of: . dot) ,
214
214
idx != _slice. startIndex
@@ -217,26 +217,26 @@ extension FilePath.Component {
217
217
return idx
218
218
}
219
219
220
- internal func _extensionRange( ) -> Range < SystemString . Index > ? {
220
+ internal func _extensionRange( ) -> Range < _SystemString . Index > ? {
221
221
guard let idx = _extensionIndex ( ) else { return nil }
222
222
return _slice. index ( after: idx) ..< _slice. endIndex
223
223
}
224
224
225
- internal func _stemRange( ) -> Range < SystemString . Index > {
225
+ internal func _stemRange( ) -> Range < _SystemString . Index > {
226
226
_slice. startIndex ..< ( _extensionIndex ( ) ?? _slice. endIndex)
227
227
}
228
228
}
229
229
230
- internal func _makeExtension( _ ext: String ) -> SystemString {
231
- var result = SystemString ( )
230
+ internal func _makeExtension( _ ext: String ) -> _SystemString {
231
+ var result = _SystemString ( )
232
232
result. append ( . dot)
233
- result. append ( contentsOf: ext. unicodeScalars. lazy. map ( SystemChar . init) )
233
+ result. append ( contentsOf: ext. unicodeScalars. lazy. map ( _SystemChar . init) )
234
234
return result
235
235
}
236
236
237
237
@available ( /*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8 , * )
238
238
extension FilePath . Component {
239
- internal init ? ( _ str: SystemString ) {
239
+ public init ? ( _ str: _SystemString ) {
240
240
// FIXME: explicit null root? Or something else?
241
241
let path = FilePath ( str)
242
242
guard path. root == nil , path. components. count == 1 else {
@@ -249,7 +249,7 @@ extension FilePath.Component {
249
249
250
250
@available ( /*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8 , * )
251
251
extension FilePath . Root {
252
- internal init ? ( _ str: SystemString ) {
252
+ public init ? ( _ str: _SystemString ) {
253
253
// FIXME: explicit null root? Or something else?
254
254
let path = FilePath ( str)
255
255
guard path. root != nil , path. components. isEmpty else {
@@ -265,7 +265,7 @@ extension FilePath.Root {
265
265
@available ( /*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8 , * )
266
266
extension FilePath . Component {
267
267
// TODO: ensure this all gets easily optimized away in release...
268
- internal func _invariantCheck( ) {
268
+ public func _invariantCheck( ) {
269
269
#if DEBUG
270
270
precondition ( !_slice. isEmpty)
271
271
precondition ( _slice. last != . null)
@@ -277,7 +277,7 @@ extension FilePath.Component {
277
277
278
278
@available ( /*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8 , * )
279
279
extension FilePath . Root {
280
- internal func _invariantCheck( ) {
280
+ public func _invariantCheck( ) {
281
281
#if DEBUG
282
282
precondition ( self . _rootEnd > _path. _storage. startIndex)
283
283
0 commit comments