@@ -52,6 +52,8 @@ extension FilePath {
5252 /// * `\Users`
5353 public var isRelative : Bool { !isAbsolute }
5454
55+ // TODO(Windows docs): examples with roots, such as whether `\foo\bar`
56+ // starts with `C:\foo`
5557 /// Returns whether `other` is a prefix of `self`, only considering
5658 /// whole path components.
5759 ///
@@ -63,15 +65,14 @@ extension FilePath {
6365 /// path.starts(with: "/usr/bin/ls") // true
6466 /// path.starts(with: "/usr/bin/ls///") // true
6567 /// path.starts(with: "/us") // false
66- ///
67- // TODO(Windows docs): examples with roots, such as whether `\foo\bar`
68- // starts with `C:\foo`
6968 public func starts( with other: FilePath ) -> Bool {
7069 guard !other. isEmpty else { return true }
7170 return self . root == other. root && components. starts (
7271 with: other. components)
7372 }
7473
74+ // TODO(Windows docs): examples with roots, such as whether `C:\foo\bar`
75+ // ends with `C:bar`
7576 /// Returns whether `other` is a suffix of `self`, only considering
7677 /// whole path components.
7778 ///
@@ -83,9 +84,6 @@ extension FilePath {
8384 /// path.ends(with: "usr/bin/ls") // true
8485 /// path.ends(with: "/usr/bin/ls///") // true
8586 /// path.ends(with: "/ls") // false
86- ///
87- // TODO(Windows docs): examples with roots, such as whether `C:\foo\bar`
88- // ends with `C:bar`
8987 public func ends( with other: FilePath ) -> Bool {
9088 if other. root != nil {
9189 // TODO: anything tricky here for Windows?
@@ -145,7 +143,6 @@ extension FilePath {
145143 /// path.root = nil // path is #"foo\bar"#
146144 /// path.root = "C:" // path is #"C:foo\bar"#
147145 /// path.root = #"C:\"# // path is #"C:\foo\bar"#
148- ///
149146 public var root : FilePath . Root ? {
150147 get {
151148 guard _hasRoot else { return nil }
@@ -178,7 +175,6 @@ extension FilePath {
178175 /// * `\\?\device\folder\file.exe => folder\file.exe`
179176 /// * `\\server\share\file => file`
180177 /// * `\ => ""`
181- ///
182178 public __consuming func removingRoot( ) -> FilePath {
183179 var copy = self
184180 copy. root = nil
@@ -209,7 +205,6 @@ extension FilePath {
209205 /// * `\\?\UNC\server\share\bar.exe => bar.exe`
210206 /// * `\\server\share => nil`
211207 /// * `\\?\UNC\server\share\ => nil`
212- ///
213208 public var lastComponent : Component ? { components. last }
214209
215210 /// Creates a new path with everything up to but not including
@@ -247,7 +242,6 @@ extension FilePath {
247242 /// path.removeLastComponent() == true // path is "/usr"
248243 /// path.removeLastComponent() == true // path is "/"
249244 /// path.removeLastComponent() == false // path is "/"
250- ///
251245 @discardableResult
252246 public mutating func removeLastComponent( ) -> Bool {
253247 defer { _invariantCheck ( ) }
@@ -271,7 +265,6 @@ extension FilePath.Component {
271265 /// * `Foo.app => app`
272266 /// * `.hidden => nil`
273267 /// * `.. => nil`
274- ///
275268 public var `extension` : String ? {
276269 guard let range = _extensionRange ( ) else { return nil }
277270 return _slice [ range] . string
@@ -285,7 +278,6 @@ extension FilePath.Component {
285278 /// * `Foo.app => Foo`
286279 /// * `.hidden => .hidden`
287280 /// * `.. => ..`
288- ///
289281 public var stem : String {
290282 _slice [ _stemRange ( ) ] . string
291283 }
@@ -322,7 +314,6 @@ extension FilePath {
322314 /// path.extension = "o" // path is "/tmp/file.o"
323315 /// path.extension = nil // path is "/tmp/file"
324316 /// path.extension = "" // path is "/tmp/file."
325- ///
326317 public var `extension` : String ? {
327318 get { lastComponent? . extension }
328319 set {
@@ -441,6 +432,7 @@ extension FilePath {
441432// Modification and concatenation API
442433/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
443434extension FilePath {
435+ // TODO(Windows docs): example with roots
444436 /// If `prefix` is a prefix of `self`, removes it and returns `true`.
445437 /// Otherwise returns `false`.
446438 ///
@@ -450,8 +442,6 @@ extension FilePath {
450442 /// path.removePrefix("/usr/bin") // false
451443 /// path.removePrefix("/us") // false
452444 /// path.removePrefix("/usr/local") // true, path is "bin"
453- ///
454- // TODO(Windows docs): example with roots
455445 public mutating func removePrefix( _ prefix: FilePath ) -> Bool {
456446 defer { _invariantCheck ( ) }
457447 // FIXME: Should Windows have more nuanced semantics?
@@ -462,6 +452,7 @@ extension FilePath {
462452 return true
463453 }
464454
455+ // TODO(Windows docs): example with roots
465456 /// Append a `component` on to the end of this path.
466457 ///
467458 /// Example:
@@ -472,13 +463,12 @@ extension FilePath {
472463 /// path.append(comp)
473464 /// }
474465 /// // path is "/tmp/foo/bar/../baz"
475- ///
476- // TODO(Windows docs): example with roots
477466 public mutating func append( _ component: __owned FilePath. Component ) {
478467 defer { _invariantCheck ( ) }
479468 _append ( unchecked: component. _slice)
480469 }
481470
471+ // TODO(Windows docs): example with roots
482472 /// Append `components` on to the end of this path.
483473 ///
484474 /// Example:
@@ -487,8 +477,6 @@ extension FilePath {
487477 /// path.append(["usr", "local"]) // path is "/usr/local"
488478 /// let otherPath: FilePath = "/bin/ls"
489479 /// path.append(otherPath.components) // path is "/usr/local/bin/ls"
490- ///
491- // TODO(Windows docs): example with roots
492480 public mutating func append< C: Collection > (
493481 _ components: __owned C
494482 ) where C. Element == FilePath . Component {
@@ -498,6 +486,8 @@ extension FilePath {
498486 }
499487 }
500488
489+ // TODO(Windows docs): example with roots, should we rephrase this "spurious
490+ // roots"?
501491 /// Append the contents of `other`, ignoring any spurious leading separators.
502492 ///
503493 /// A leading separator is spurious if `self` is non-empty.
@@ -508,9 +498,6 @@ extension FilePath {
508498 /// path.append("/var/www/website") // "/var/www/website"
509499 /// path.append("static/assets") // "/var/www/website/static/assets"
510500 /// path.append("/main.css") // "/var/www/website/static/assets/main.css"
511- ///
512- // TODO(Windows docs): example with roots, should we rephrase this "spurious
513- // roots"?
514501 public mutating func append( _ other: __owned String) {
515502 defer { _invariantCheck ( ) }
516503 guard !other. utf8. isEmpty else { return }
@@ -522,18 +509,16 @@ extension FilePath {
522509 _append ( unchecked: otherPath. _storage [ otherPath. _relativeStart... ] )
523510 }
524511
525- /// Non-mutating version of `append(_:Component)`.
526- ///
527512 // TODO(Windows docs): example with roots
513+ /// Non-mutating version of `append(_:Component)`.
528514 public __consuming func appending( _ other: __owned Component) -> FilePath {
529515 var copy = self
530516 copy. append ( other)
531517 return copy
532518 }
533519
534- /// Non-mutating version of `append(_:C)`.
535- ///
536520 // TODO(Windows docs): example with roots
521+ /// Non-mutating version of `append(_:C)`.
537522 public __consuming func appending< C: Collection > (
538523 _ components: __owned C
539524 ) -> FilePath where C. Element == FilePath . Component {
@@ -542,15 +527,16 @@ extension FilePath {
542527 return copy
543528 }
544529
545- /// Non-mutating version of `append(_:String)`.
546- ///
547530 // TODO(Windows docs): example with roots
531+ /// Non-mutating version of `append(_:String)`.
548532 public __consuming func appending( _ other: __owned String) -> FilePath {
549533 var copy = self
550534 copy. append ( other)
551535 return copy
552536 }
553537
538+ // TODO(Windows docs): examples and docs with roots, update/generalize doc
539+ // comment
554540 /// If `other` does not have a root, append each component of `other`. If
555541 /// `other` has a root, replaces `self` with other.
556542 ///
@@ -564,9 +550,6 @@ extension FilePath {
564550 /// var path: FilePath = "/tmp"
565551 /// path.push("dir/file.txt") // path is "/tmp/dir/file.txt"
566552 /// path.push("/bin") // path is "/bin"
567- ///
568- // TODO(Windows docs): examples and docs with roots, update/generalize doc
569- // comment
570553 public mutating func push( _ other: __owned FilePath) {
571554 defer { _invariantCheck ( ) }
572555 guard other. root == nil else {
@@ -577,9 +560,8 @@ extension FilePath {
577560 _append ( unchecked: other. _storage [ ... ] )
578561 }
579562
580- /// Non-mutating version of `push()`.
581- ///
582563 // TODO(Windows docs): examples and docs with roots
564+ /// Non-mutating version of `push()`.
583565 public __consuming func pushing( _ other: __owned FilePath) -> FilePath {
584566 var copy = self
585567 copy. push ( other)
0 commit comments