Skip to content

Commit 05e3d04

Browse files
committed
Drop Component.isSpecialDirectory
This API is fully redundant with .kind == .regular and could be a source of confusion and namespace pollution. Drop it for now, and we can add something equivalent in the future when we have more component-analysis APIs.
1 parent 2167575 commit 05e3d04

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

Sources/System/FilePath/FilePathComponents.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ extension FilePath.Component {
9494
if _path._isParentDirectory(_range) { return .parentDirectory }
9595
return .regular
9696
}
97-
98-
/// Whether this component is either special directory `.` or `..`.
99-
public var isSpecialDirectory: Bool { _path._isSpecialDirectory(_range) }
10097
}
10198

10299
extension FilePath.Root {
@@ -207,7 +204,7 @@ extension FilePath: _PlatformStringable {
207204
extension FilePath.Component {
208205
// The index of the `.` denoting an extension
209206
internal func _extensionIndex() -> SystemString.Index? {
210-
guard !isSpecialDirectory,
207+
guard kind == .regular,
211208
let idx = _slice.lastIndex(of: .dot),
212209
idx != _slice.startIndex
213210
else { return nil }

Sources/System/FilePath/FilePathSyntax.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ extension FilePath {
325325
get { lastComponent?.extension }
326326
set {
327327
defer { _invariantCheck() }
328-
guard let base = lastComponent, !base.isSpecialDirectory else { return }
328+
guard let base = lastComponent, base.kind == .regular else { return }
329329

330330
let suffix: SystemString
331331
if let ext = newValue {
@@ -373,7 +373,7 @@ extension FilePath {
373373
// `\..\foo\bar` should not.
374374
components.drop(
375375
while: { root == nil && $0.kind == .parentDirectory }
376-
).allSatisfy { !$0.isSpecialDirectory }
376+
).allSatisfy { $0.kind == .regular }
377377
}
378378

379379
/// Collapse `.` and `..` components lexically (i.e. without following

Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,14 +916,12 @@ final class FilePathSyntaxTest: XCTestCase {
916916
path.append(".")
917917
expect("/.")
918918
XCTAssert(path.components.last!.kind == .currentDirectory)
919-
XCTAssert(path.components.last!.isSpecialDirectory)
920919
path.lexicallyNormalize()
921920
expect("/")
922921

923922
path.append("..")
924923
expect("/..")
925924
XCTAssert(path.components.last!.kind == .parentDirectory)
926-
XCTAssert(path.components.last!.isSpecialDirectory)
927925
path.lexicallyNormalize()
928926
expect("/")
929927

0 commit comments

Comments
 (0)