mirror of
				https://github.com/GayPizzaSpecifications/darwin-apk.git
				synced 2025-11-03 23:49:38 +00:00 
			
		
		
		
	Rescue graph building test into subcommand
This commit is contained in:
		@ -1,29 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * darwin-apk © 2024 Gay Pizza Specifications
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import Foundation
 | 
			
		||||
import Darwin
 | 
			
		||||
 | 
			
		||||
struct TextFileWriter: TextOutputStream {
 | 
			
		||||
  private var _hnd: FileHandle
 | 
			
		||||
 | 
			
		||||
  init?(_ to: URL) {
 | 
			
		||||
    let file = open(to.path(), O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, 0o644)
 | 
			
		||||
    guard file >= 0 else {
 | 
			
		||||
      return nil
 | 
			
		||||
    }
 | 
			
		||||
    self._hnd = FileHandle(fileDescriptor: file, closeOnDealloc: true)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  mutating func write(_ string: String) {
 | 
			
		||||
    if let data = string.data(using: .utf8) {
 | 
			
		||||
      try? self._hnd.write(contentsOf: data)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  mutating func close() throws {
 | 
			
		||||
    try self._hnd.close()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user