Rename WriteableStream to WritableStream.

Because that is the spelling Apple uses.
This commit is contained in:
Kare Morstol
2017-01-25 18:50:56 +01:00
parent 4145afefd8
commit eca353d338
3 changed files with 14 additions and 14 deletions
+6 -6
View File
@@ -12,8 +12,8 @@ public protocol ShellContextType: CustomDebugStringConvertible {
var env: [String: String] {get set}
var stdin: ReadableStream {get set}
var stdout: WriteableStream {get set}
var stderror: WriteableStream {get set}
var stdout: WritableStream {get set}
var stderror: WritableStream {get set}
/**
The current working directory.
@@ -39,8 +39,8 @@ public struct ShellContext: ShellContextType {
public var env: [String: String]
public var stdin: ReadableStream
public var stdout: WriteableStream
public var stderror: WriteableStream
public var stdout: WritableStream
public var stderror: WritableStream
/**
The current working directory.
@@ -112,8 +112,8 @@ public final class MainShellContext: ShellContextType {
public lazy var env = ProcessInfo.processInfo.environment as [String: String]
public lazy var stdin: ReadableStream = { FileHandleStream(FileHandle.standardInput, encoding: self.encoding) }()
public lazy var stdout: WriteableStream = { StdoutStream.default }()
public lazy var stderror: WriteableStream = { FileHandleStream(FileHandle.standardError, encoding: self.encoding) }()
public lazy var stdout: WritableStream = { StdoutStream.default }()
public lazy var stderror: WritableStream = { FileHandleStream(FileHandle.standardError, encoding: self.encoding) }()
/**
The current working directory.
+2 -2
View File
@@ -60,7 +60,7 @@ If the file already exists and overwrite=false, the writing will begin at the en
- parameter overwrite: If true, replace the file if it exists.
*/
public func open (forWriting path: URL, overwrite: Bool = false, encoding: String.Encoding = main.encoding) throws -> WriteableStream {
public func open (forWriting path: URL, overwrite: Bool = false, encoding: String.Encoding = main.encoding) throws -> WritableStream {
if overwrite || !Files.fileExists(atPath: path.path) {
_ = Files.createFile(atPath: path.path, contents: nil, attributes: nil)
@@ -82,7 +82,7 @@ If the file already exists and overwrite=false, the writing will begin at the en
- parameter overwrite: If true, replace the file if it exists.
*/
public func open (forWriting path: String, overwrite: Bool = false, encoding: String.Encoding = main.encoding) throws -> WriteableStream {
public func open (forWriting path: String, overwrite: Bool = false, encoding: String.Encoding = main.encoding) throws -> WritableStream {
let fixedpath = path.hasPrefix("~") ? NSString(string: path).expandingTildeInPath : path
return try open(forWriting: URL(fileURLWithPath: fixedpath, isDirectory: false), overwrite: overwrite, encoding: encoding)
}
+6 -6
View File
@@ -114,7 +114,7 @@ extension ReadableStream {
/** An output stream, like standard output or a writeable file. */
public protocol WriteableStream : class, TextOutputStream {
public protocol WritableStream : class, TextOutputStream {
var filehandle: FileHandle { get }
var encoding: String.Encoding {get set}
@@ -126,7 +126,7 @@ public protocol WriteableStream : class, TextOutputStream {
func close ()
}
extension WriteableStream {
extension WritableStream {
/**
Writes the textual representations of the given items into the stream.
@@ -143,7 +143,7 @@ extension WriteableStream {
}
}
extension FileHandleStream: WriteableStream {
extension FileHandleStream: WritableStream {
public func write <T> (_ x: T) {
if filehandle.fileDescriptor == STDOUT_FILENO {
@@ -158,8 +158,8 @@ extension FileHandleStream: WriteableStream {
}
}
/** Singleton WriteableStream used only for `print`ing to stdout with the default main.stdout. */
internal class StdoutStream: WriteableStream {
/** Singleton WritableStream used only for `print`ing to stdout with the default main.stdout. */
internal class StdoutStream: WritableStream {
public var filehandle: FileHandle {
return FileHandle.standardOutput
}
@@ -178,7 +178,7 @@ internal class StdoutStream: WriteableStream {
}
/** Create a pair of streams. What is written to the 1st one can be read from the 2nd one. */
public func streams () -> (WriteableStream, ReadableStream) {
public func streams () -> (WritableStream, ReadableStream) {
let pipe = Pipe()
return (FileHandleStream(pipe.fileHandleForWriting), FileHandleStream(pipe.fileHandleForReading))
}