Skip to content

Commit 92b84e4

Browse files
authored
[6.0] Fix ProcessInfo.processName for Windows (#839) (#840)
Instead of relying on hard coding PATH_SEPARATOR, use existing .lastPathComponent that already works on Windows
1 parent 057297d commit 92b84e4

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

Sources/FoundationEssentials/Platform.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ package struct Platform {
4949
_pageSize
5050
}
5151

52-
// FIXME: Windows SEPARATOR
53-
static let PATH_SEPARATOR: Character = "/"
5452
static let MAX_HOSTNAME_LENGTH = 1024
5553

5654
static func roundDownToMultipleOfPageSize(_ size: Int) -> Int {

Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,7 @@ extension _ProcessInfo {
581581
guard let processPath = CommandLine.arguments.first else {
582582
return ""
583583
}
584-
585-
if let lastSlash = processPath.lastIndex(of: Platform.PATH_SEPARATOR) {
586-
return String(processPath[
587-
processPath.index(after: lastSlash) ..< processPath.endIndex])
588-
}
589-
590-
return processPath
584+
return processPath.lastPathComponent
591585
}
592586

593587
#if os(macOS)

0 commit comments

Comments
 (0)