StandardErrorOutputStream.swift 680 B

1234567891011121314151617181920
  1. // Sources/SwiftProtobufPluginLibrary/StandardErrorOutputStream.swift
  2. //
  3. // Copyright (c) 2014 - 2023 Apple Inc. and the project authors
  4. // Licensed under Apache License v2.0 with Runtime Library Exception
  5. //
  6. // See LICENSE.txt for license information:
  7. // https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt
  8. //
  9. import Foundation
  10. class StandardErrorOutputStream: TextOutputStream {
  11. func write(_ string: String) {
  12. if #available(macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *) {
  13. try! FileHandle.standardError.write(contentsOf: Data(string.utf8))
  14. } else {
  15. FileHandle.standardError.write(Data(string.utf8))
  16. }
  17. }
  18. }