File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -727,13 +727,14 @@ private struct UNIXPath: Path {
727
727
728
728
func suffix( withDot: Bool ) -> String ? {
729
729
#if os(Windows)
730
- let ext = self . string. withCString ( encodedAs: UTF16 . self) {
731
- PathFindExtensionW ( $0)
730
+ return self . string. withCString ( encodedAs: UTF16 . self) {
731
+ if let pointer = PathFindExtensionW ( $0) {
732
+ let substring = String ( decodingCString: pointer, as: UTF16 . self)
733
+ guard substring. length > 0 else { return nil }
734
+ return withDot ? substring : String ( substring. dropFirst ( 1 ) )
735
+ }
736
+ return nil
732
737
}
733
- var result = String ( decodingCString: ext!, as: UTF16 . self)
734
- guard result. length > 0 else { return nil }
735
- if !withDot { result. removeFirst ( 1 ) }
736
- return result
737
738
#else
738
739
// FIXME: This method seems too complicated; it should be simplified,
739
740
// if possible, and certainly optimized (using UTF8View).
You can’t perform that action at this time.
0 commit comments