Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LSWrapper
- def initialize(path)
- @task = NSTask.alloc.initWithPath(path)
- end
- def launch(*args)
- task.standardInput = NSPipe.alloc.init
- task.standardOutput = NSPipe.alloc.init
- task.standardError = NSPipe.alloc.init
- NSNotificationCenter.defaultCenter.addObserver(self, selector:"ready:", name:NSTaskDidTerminateNotification)
- task.arguments = arguments
- task.launch
- end
- def ready(notification)
- output_data = task.standardOutput.fileHandleForReading.readDataToEndOfFile
- error_data = task.standardError.fileHandleForReading.readDataToEndOfFile
- output = NSString.alloc.initWithData(output_data, encoding:NSUTF8StringEncoding)
- output = NSString.alloc.initWithData(error_data, encoding:NSUTF8StringEncoding)
- # Where you were with the block
- end
- end
Add Comment
Please, Sign In to add comment