Skip to content

Commit 33f7857

Browse files
committed
SwiftLintCore: initial pass for Windows support
Add some Windows specific handling for the paths in SwiftLintCore. The one piece that this change does not cover is the handling of `glob` as that is not an ISO C standard function and as such there is no `glob` on Windows. This will be worked through separately.
1 parent 5d35f8b commit 33f7857

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Source/SwiftLintCore/Extensions/Configuration+Remote.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import Foundation // swiftlint:disable:this file_name
44
import FoundationNetworking
55
#endif
66

7+
#if os(Windows)
8+
import func WinSDK.Sleep
9+
#endif
10+
711
internal extension Configuration.FileGraph.FilePath {
812
// MARK: - Properties: Remote Cache
913
/// This should never be touched.
@@ -87,7 +91,11 @@ internal extension Configuration.FileGraph.FilePath {
8791
while true {
8892
if taskDone { break }
8993
if Date().timeIntervalSince(startDate) > timeout { task.cancel(); break }
94+
#if os(Windows)
95+
Sleep(50)
96+
#else
9097
usleep(50_000) // Sleep for 50 ms
98+
#endif
9199
}
92100

93101
// Handle wrong data

Source/SwiftLintCore/Helpers/Reachability.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !os(Linux)
1+
#if !os(Linux) && !os(Windows)
22
import SystemConfiguration
33
#endif
44

@@ -9,9 +9,9 @@ enum Reachability {
99
}
1010

1111
/// Returns whether the device is connected to a network, if known.
12-
/// On Linux, this always evaluates to `nil`.
12+
/// On Linux and Windows, this always evaluates to `nil`.
1313
static var connectivityStatus: ConnectivityStatus {
14-
#if os(Linux)
14+
#if os(Linux) || os(Windows)
1515
return .unknown
1616
#else
1717
var zeroAddress = sockaddr_in()

0 commit comments

Comments
 (0)