Skip to content

Commit 5066750

Browse files
compnerdspevans
authored andcommitted
NSPipe: make fileHandleFor{Reading,Writing} mutable
In Objective-C, the fileHandleFor{Reading,Writing} property is mutable even on a const instance. Change the property to read/write. (cherry picked from commit 09cfc21)
1 parent 5acae43 commit 5066750

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

Foundation/FileHandle.swift

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,9 @@ extension FileHandle {
368368
}
369369

370370
open class Pipe: NSObject {
371-
private let readHandle: FileHandle
372-
private let writeHandle: FileHandle
373-
371+
open let fileHandleForReading: FileHandle
372+
open let fileHandleForWriting: FileHandle
373+
374374
public override init() {
375375
/// the `pipe` system call creates two `fd` in a malloc'ed area
376376
var fds = UnsafeMutablePointer<Int32>.allocate(capacity: 2)
@@ -384,19 +384,11 @@ open class Pipe: NSObject {
384384
/// don't need to add a `deinit` to this class
385385

386386
/// Create the read handle from the first fd in `fds`
387-
self.readHandle = FileHandle(fileDescriptor: fds.pointee, closeOnDealloc: true)
387+
self.fileHandleForReading = FileHandle(fileDescriptor: fds.pointee, closeOnDealloc: true)
388388

389389
/// Advance `fds` by one to create the write handle from the second fd
390-
self.writeHandle = FileHandle(fileDescriptor: fds.successor().pointee, closeOnDealloc: true)
390+
self.fileHandleForWriting = FileHandle(fileDescriptor: fds.successor().pointee, closeOnDealloc: true)
391391

392392
super.init()
393393
}
394-
395-
open var fileHandleForReading: FileHandle {
396-
return self.readHandle
397-
}
398-
399-
open var fileHandleForWriting: FileHandle {
400-
return self.writeHandle
401-
}
402394
}

0 commit comments

Comments
 (0)