diff --git a/Sources/SwiftShell/Context.swift b/Sources/SwiftShell/Context.swift index c16b09b..57773e6 100755 --- a/Sources/SwiftShell/Context.swift +++ b/Sources/SwiftShell/Context.swift @@ -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. diff --git a/Sources/SwiftShell/Files.swift b/Sources/SwiftShell/Files.swift index 18133b0..0c0e21f 100755 --- a/Sources/SwiftShell/Files.swift +++ b/Sources/SwiftShell/Files.swift @@ -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) } diff --git a/Sources/SwiftShell/Stream.swift b/Sources/SwiftShell/Stream.swift index aa7f706..40b71e3 100755 --- a/Sources/SwiftShell/Stream.swift +++ b/Sources/SwiftShell/Stream.swift @@ -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 (_ 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)) }