Skip to content

Commit 5afdac0

Browse files
Rework and rename package
1 parent 6b8e9f3 commit 5afdac0

File tree

10 files changed

+29
-82
lines changed

10 files changed

+29
-82
lines changed

.spi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version: 1
22
builder:
33
configs:
4-
- documentation_targets: [LightTableFilePaths]
4+
- documentation_targets: [ScopedFilePath]

Package.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// swift-tools-version: 5.10
1+
// swift-tools-version: 6.0
22
import PackageDescription
33

44
let package = Package(
5-
name: "LightTableFilePaths",
5+
name: "swift-scoped-file-path",
66
platforms: [
77
.macOS(.v12),
88
.iOS(.v15),
@@ -13,15 +13,12 @@ let package = Package(
1313
],
1414
products: [
1515
.library(
16-
name: "LightTableFilePaths",
17-
targets: ["LightTableFilePaths"]),
16+
name: "ScopedFilePath",
17+
targets: ["ScopedFilePath"]),
1818
],
1919
targets: [
2020
.target(
21-
name: "LightTableFilePaths"),
22-
.testTarget(
23-
name: "LightTableFilePathsTests",
24-
dependencies: ["LightTableFilePaths"]),
21+
name: "ScopedFilePath"),
2522
]
2623
)
2724

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# LightTableFilePaths
1+
# Swift Scoped File Path
22

33
A Swift package introducing separate `AbsoluteFilePath` and `RelativeFilePath` based on `FilePath` from [Swift System](https://github.com/apple/swift-system).

Sources/FilePath.Component.swift

Lines changed: 0 additions & 31 deletions
This file was deleted.

Sources/AbsoluteFilePath.swift renamed to Sources/ScopedFilePath/AbsoluteFilePath.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
//
2-
// AbsoluteFilePath.swift
3-
// LightTableFilePaths
4-
//
52
// Copyright 2024 Florian Pircher
63
//
74
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,7 +21,7 @@ import System
2421
import SystemPackage
2522
#endif
2623

27-
public struct AbsoluteFilePath: ExtendedFilePath, Sendable {
24+
public struct AbsoluteFilePath: ScopedFilePathProtocol, Sendable {
2825
public let storage: FilePath
2926

3027
public init?(_ path: FilePath) {

Sources/Documentation.docc/Documentation.md renamed to Sources/ScopedFilePath/Documentation.docc/Documentation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ``LightTableFilePaths``
1+
# ``ScopedFilePath``
22

33
Separate `AbsoluteFilePath` and `RelativeFilePath` types.
44

@@ -20,4 +20,4 @@ Both are immutable and offer API specific to their use cases.
2020

2121
### Abstraction
2222

23-
- ``ExtendedFilePath``
23+
- ``ScopedFilePathProtocol``

Sources/FilePathCompareOptions.swift renamed to Sources/ScopedFilePath/FilePathCompareOptions.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
//
2-
// FilePathCompareOptions.swift
3-
// LightTableFilePaths
4-
//
52
// Copyright 2024 Florian Pircher
63
//
74
// Licensed under the Apache License, Version 2.0 (the "License");

Sources/RelativeFilePath.swift renamed to Sources/ScopedFilePath/RelativeFilePath.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
//
2-
// RelativeFilePath.swift
3-
// LightTableFilePaths
4-
//
52
// Copyright 2024 Florian Pircher
63
//
74
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,7 +21,7 @@ import System
2421
import SystemPackage
2522
#endif
2623

27-
public struct RelativeFilePath: ExtendedFilePath, ExpressibleByStringLiteral, Sendable {
24+
public struct RelativeFilePath: ScopedFilePathProtocol, ExpressibleByStringLiteral, Sendable {
2825
public let storage: FilePath
2926

3027
public init?(_ path: FilePath) {

Sources/ExtendedFilePath.swift renamed to Sources/ScopedFilePath/ScopedFilePathProtocol.swift

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
//
2-
// ExtendedFilePath.swift
3-
// LightTableFilePaths
4-
//
52
// Copyright 2024 Florian Pircher
63
//
74
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,7 +21,7 @@ import System
2421
import SystemPackage
2522
#endif
2623

27-
public protocol ExtendedFilePath: Hashable, CustomStringConvertible {
24+
public protocol ScopedFilePathProtocol: Hashable, CustomStringConvertible {
2825
typealias Component = FilePath.Component
2926
typealias CompareOptions = FilePathCompareOptions
3027

@@ -33,13 +30,13 @@ public protocol ExtendedFilePath: Hashable, CustomStringConvertible {
3330
init?(_ path: FilePath)
3431
}
3532

36-
extension ExtendedFilePath {
37-
public var components: FilePath.ComponentView { storage.components }
38-
public var lastComponent: FilePath.Component? { storage.lastComponent }
39-
public var description: String { storage.string }
40-
public var string: String { storage.string }
41-
public var stem: String? { storage.stem }
42-
public var `extension`: String? { storage.extension }
33+
extension ScopedFilePathProtocol {
34+
public var components: FilePath.ComponentView { self.storage.components }
35+
public var lastComponent: FilePath.Component? { self.storage.lastComponent }
36+
public var description: String { self.storage.string }
37+
public var string: String { self.storage.string }
38+
public var stem: String? { self.storage.stem }
39+
public var `extension`: String? { self.storage.extension }
4340

4441
public init?(platformString: [CInterop.PlatformChar]) {
4542
self.init(FilePath(platformString: platformString))
@@ -58,53 +55,49 @@ extension ExtendedFilePath {
5855
}
5956

6057
public static func == (lhs: Self, rhs: Self) -> Bool {
61-
lhs.storage == rhs.storage
58+
lhs.self.storage == rhs.self.storage
6259
}
6360

6461
public func hash(into hasher: inout Hasher) {
65-
hasher.combine(storage)
62+
hasher.combine(self.storage)
6663
}
6764

6865
public var isEmpty: Bool {
69-
storage.isEmpty
66+
self.storage.isEmpty
7067
}
7168

7269
public func appending(_ other: String) -> Self {
73-
Self(storage.appending(other))!
70+
Self(self.storage.appending(other))!
7471
}
7572

7673
public func appending(_ other: FilePath.Component) -> Self {
77-
Self(storage.appending(other))!
74+
Self(self.storage.appending(other))!
7875
}
7976

8077
public func appending(_ components: some Collection<FilePath.Component>) -> Self {
81-
Self(storage.appending(components))!
78+
Self(self.storage.appending(components))!
8279
}
8380

8481
public func withExtension(_ `extension`: String?) -> Self {
85-
var valueCopy = storage
82+
var valueCopy = self.storage
8683

8784
valueCopy.extension = `extension`
8885

8986
return Self(valueCopy)!
9087
}
9188

9289
public func removingLastComponent() -> Self {
93-
Self(storage.removingLastComponent())!
90+
Self(self.storage.removingLastComponent())!
9491
}
9592

9693
public func starts(with prefix: Self, options: FilePathCompareOptions) -> Bool {
9794
if options.contains(.unicodeEquality) {
98-
storage.components.starts(with: prefix.components) { a, b in
95+
self.storage.components.starts(with: prefix.components) { a, b in
9996
a.string == b.string
10097
}
10198
}
10299
else {
103-
storage.starts(with: prefix.storage)
100+
self.storage.starts(with: prefix.self.storage)
104101
}
105102
}
106-
107-
public func withPrecomposedString<R>(_ body: (UnsafePointer<CInterop.PlatformChar>) throws -> R) rethrows -> R {
108-
try self.storage.string.precomposedStringWithCanonicalMapping.withCString(body)
109-
}
110103
}

Sources/URL.swift renamed to Sources/ScopedFilePath/URL.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
//
2-
// URL.swift
3-
// LightTableFilePaths
4-
//
52
// Copyright 2024 Florian Pircher
63
//
74
// Licensed under the Apache License, Version 2.0 (the "License");

0 commit comments

Comments
 (0)