Skip to content

Commit 0c124a9

Browse files
authored
Fix ProcessInfo.processName for Windows (#839)
Instead of relying on hard coding PATH_SEPARATOR, use existing .lastPathComponent that already works on Windows
1 parent 653aa2a commit 0c124a9

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
@@ -583,13 +583,7 @@ extension _ProcessInfo {
583583
guard let processPath = CommandLine.arguments.first else {
584584
return ""
585585
}
586-
587-
if let lastSlash = processPath.lastIndex(of: Platform.PATH_SEPARATOR) {
588-
return String(processPath[
589-
processPath.index(after: lastSlash) ..< processPath.endIndex])
590-
}
591-
592-
return processPath
586+
return processPath.lastPathComponent
593587
}
594588

595589
#if os(macOS)

0 commit comments

Comments
 (0)