Skip to content

Commit a132f6e

Browse files
authored
Merge pull request #1955 from compnerd/incase-of-emergency-glue-the-window
HACK: make FileHandle build on Windows again
2 parents 0a6f09b + fc0f8d6 commit a132f6e

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Foundation/FileHandle.swift

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,6 @@ open class FileHandle : NSObject, NSSecureCoding {
134134
return source
135135
}
136136

137-
#if os(Windows)
138-
@available(*, unavailable, message: "Not yet implemented on Windows")
139-
open var readabilityHandler: ((FileHandle) -> Void)? = {
140-
(FileHandle) -> Void in NSUnimplemented()
141-
}
142-
143-
@available(*, unavailable, message: "Not yet implemented on Windows")
144-
open var writeabilityHandler: ((FileHandle) -> Void)? = {
145-
(FileHandle) -> Void in NSUnimplemented()
146-
}
147-
#else
148137
private var _readabilityHandler: ((FileHandle) -> Void)? = nil // Guarded by privateAsyncVariablesLock
149138
open var readabilityHandler: ((FileHandle) -> Void)? {
150139
get {
@@ -200,7 +189,6 @@ open class FileHandle : NSObject, NSSecureCoding {
200189
}
201190
}
202191
}
203-
#endif
204192

205193
open var availableData: Data {
206194
_checkFileHandle()
@@ -891,7 +879,11 @@ extension FileHandle {
891879
acceptConnectionInBackgroundAndNotify(forModes: [.default])
892880
}
893881

882+
@available(Windows, unavailable, message: "A SOCKET cannot be treated as a fd")
894883
open func acceptConnectionInBackgroundAndNotify(forModes modes: [RunLoop.Mode]?) {
884+
#if os(Windows)
885+
NSUnavailable()
886+
#else
895887
let owner = monitor(forReading: true, resumed: false) { (handle, source) in
896888
var notification = Notification(name: .NSFileHandleConnectionAccepted, object: handle, userInfo: [:])
897889
let userInfo: [AnyHashable : Any]
@@ -919,6 +911,7 @@ extension FileHandle {
919911
privateAsyncVariablesLock.unlock()
920912

921913
owner.resume()
914+
#endif
922915
}
923916

924917
open func waitForDataInBackgroundAndNotify() {

0 commit comments

Comments
 (0)