Skip to content

Commit

Permalink
Split the sensor util from main
Browse files Browse the repository at this point in the history
  • Loading branch information
op06072 committed Jan 27, 2024
1 parent c720306 commit 0309eb0
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 29 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 0 additions & 29 deletions socpowerbuddy_swift/helper.swift → SensorUtil/helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,32 +179,3 @@ public func Temperature(_ value: Double, defaultUnit: UnitTemperature = UnitTemp

return formatter.string(from: measurement)
}

public func process(path: String, arguments: [String]) -> String? {
let task = Process()
task.launchPath = path
task.arguments = arguments

let outputPipe = Pipe()
defer {
outputPipe.fileHandleForReading.closeFile()
}
task.standardOutput = outputPipe

do {
try task.run()
} catch let error {
print("Failed to run SystemProfiler")
print("system_profiler \(arguments[0]): \(error.localizedDescription)")
return nil
}

let outputData = outputPipe.fileHandleForReading.readDataToEndOfFile()
let output = String(decoding: outputData, as: UTF8.self)

if output.isEmpty {
return nil
}

return output
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0309eb0

Please sign in to comment.