Skip to content

Commit 09cfc21

Browse files
committed
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.
1 parent a2b4095 commit 09cfc21

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
@@ -367,9 +367,9 @@ extension FileHandle {
367367
}
368368

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

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

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

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

0 commit comments

Comments
 (0)