mirror of
https://github.com/apple/swift-system
synced 2026-11-26 04:57:54 +00:00
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.
This commit is contained in:
1 parent
2167575e66
commit
05e3d04b0c
3 files changed
+3
-8
No files matched your search
@@ -94,9 +94,6 @@ extension FilePath.Component {
|
||||
if _path._isParentDirectory(_range) { return .parentDirectory }
|
||||
return .regular
|
||||
}
|
||||
|
||||
/// Whether this component is either special directory `.` or `..`.
|
||||
public var isSpecialDirectory: Bool { _path._isSpecialDirectory(_range) }
|
||||
}
|
||||
|
||||
extension FilePath.Root {
|
||||
@@ -207,7 +204,7 @@ extension FilePath: _PlatformStringable {
|
||||
extension FilePath.Component {
|
||||
// The index of the `.` denoting an extension
|
||||
internal func _extensionIndex() -> SystemString.Index? {
|
||||
guard !isSpecialDirectory,
|
||||
guard kind == .regular,
|
||||
let idx = _slice.lastIndex(of: .dot),
|
||||
idx != _slice.startIndex
|
||||
else { return nil }
|
||||
|
||||
@@ -325,7 +325,7 @@ extension FilePath {
|
||||
get { lastComponent?.extension }
|
||||
set {
|
||||
defer { _invariantCheck() }
|
||||
guard let base = lastComponent, !base.isSpecialDirectory else { return }
|
||||
guard let base = lastComponent, base.kind == .regular else { return }
|
||||
|
||||
let suffix: SystemString
|
||||
if let ext = newValue {
|
||||
@@ -373,7 +373,7 @@ extension FilePath {
|
||||
// `\..\foo\bar` should not.
|
||||
components.drop(
|
||||
while: { root == nil && $0.kind == .parentDirectory }
|
||||
).allSatisfy { !$0.isSpecialDirectory }
|
||||
).allSatisfy { $0.kind == .regular }
|
||||
}
|
||||
|
||||
/// Collapse `.` and `..` components lexically (i.e. without following
|
||||
|
||||
@@ -916,14 +916,12 @@ final class FilePathSyntaxTest: XCTestCase {
|
||||
path.append(".")
|
||||
expect("/.")
|
||||
XCTAssert(path.components.last!.kind == .currentDirectory)
|
||||
XCTAssert(path.components.last!.isSpecialDirectory)
|
||||
path.lexicallyNormalize()
|
||||
expect("/")
|
||||
|
||||
path.append("..")
|
||||
expect("/..")
|
||||
XCTAssert(path.components.last!.kind == .parentDirectory)
|
||||
XCTAssert(path.components.last!.isSpecialDirectory)
|
||||
path.lexicallyNormalize()
|
||||
expect("/")
|
||||
|
||||
|
||||
Reference in new issue
Block a user