1 Star 0 Fork 0

raychow-github/ios-app-signer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
NSTask-execute.swift 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
KageDev 提交于 2017-03-28 22:26 . Update NSTask-execute.swift
//
// NSTask-execute.swift
// AppSigner
//
// Created by Daniel Radtke on 11/3/15.
// Copyright © 2015 Daniel Radtke. All rights reserved.
//
import Foundation
struct AppSignerTaskOutput {
var output: String
var status: Int32
init(status: Int32, output: String){
self.status = status
self.output = output
}
}
extension Process {
func launchSyncronous() -> AppSignerTaskOutput {
self.standardInput = FileHandle.nullDevice
let pipe = Pipe()
self.standardOutput = pipe
self.standardError = pipe
let pipeFile = pipe.fileHandleForReading
self.launch()
let data = NSMutableData()
while self.isRunning {
data.append(pipeFile.availableData)
}
pipeFile.closeFile();
self.terminate();
let output = NSString(data: data as Data, encoding: String.Encoding.utf8.rawValue) as! String
return AppSignerTaskOutput(status: self.terminationStatus, output: output)
}
func execute(_ launchPath: String, workingDirectory: String?, arguments: [String]?)->AppSignerTaskOutput{
self.launchPath = launchPath
if arguments != nil {
self.arguments = arguments
}
if workingDirectory != nil {
self.currentDirectoryPath = workingDirectory!
}
return self.launchSyncronous()
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/raychow-github/ios-app-signer.git
git@gitee.com:raychow-github/ios-app-signer.git
raychow-github
ios-app-signer
ios-app-signer
master

搜索帮助