From 0309eb04a6d0206498d45da05e46155b96c1048e Mon Sep 17 00:00:00 2001 From: op06072 Date: Sat, 27 Jan 2024 15:40:02 +0900 Subject: [PATCH] Split the sensor util from main --- .../Logger.swift | 0 .../Module.swift | 0 .../Sensors.swift | 0 .../SystemKit.swift | 0 .../Types.swift | 0 .../extensions.swift | 0 .../helper.swift | 29 ------------------- .../reader.swift | 0 {socpowerbuddy_swift => SensorUtil}/readers.m | 0 .../readers.swift | 0 {socpowerbuddy_swift => SensorUtil}/smc.swift | 0 .../values.swift | 0 12 files changed, 29 deletions(-) rename {socpowerbuddy_swift => SensorUtil}/Logger.swift (100%) rename {socpowerbuddy_swift => SensorUtil}/Module.swift (100%) rename {socpowerbuddy_swift => SensorUtil}/Sensors.swift (100%) rename {socpowerbuddy_swift => SensorUtil}/SystemKit.swift (100%) rename {socpowerbuddy_swift => SensorUtil}/Types.swift (100%) rename {socpowerbuddy_swift => SensorUtil}/extensions.swift (100%) rename {socpowerbuddy_swift => SensorUtil}/helper.swift (88%) rename {socpowerbuddy_swift => SensorUtil}/reader.swift (100%) rename {socpowerbuddy_swift => SensorUtil}/readers.m (100%) rename {socpowerbuddy_swift => SensorUtil}/readers.swift (100%) rename {socpowerbuddy_swift => SensorUtil}/smc.swift (100%) rename {socpowerbuddy_swift => SensorUtil}/values.swift (100%) diff --git a/socpowerbuddy_swift/Logger.swift b/SensorUtil/Logger.swift similarity index 100% rename from socpowerbuddy_swift/Logger.swift rename to SensorUtil/Logger.swift diff --git a/socpowerbuddy_swift/Module.swift b/SensorUtil/Module.swift similarity index 100% rename from socpowerbuddy_swift/Module.swift rename to SensorUtil/Module.swift diff --git a/socpowerbuddy_swift/Sensors.swift b/SensorUtil/Sensors.swift similarity index 100% rename from socpowerbuddy_swift/Sensors.swift rename to SensorUtil/Sensors.swift diff --git a/socpowerbuddy_swift/SystemKit.swift b/SensorUtil/SystemKit.swift similarity index 100% rename from socpowerbuddy_swift/SystemKit.swift rename to SensorUtil/SystemKit.swift diff --git a/socpowerbuddy_swift/Types.swift b/SensorUtil/Types.swift similarity index 100% rename from socpowerbuddy_swift/Types.swift rename to SensorUtil/Types.swift diff --git a/socpowerbuddy_swift/extensions.swift b/SensorUtil/extensions.swift similarity index 100% rename from socpowerbuddy_swift/extensions.swift rename to SensorUtil/extensions.swift diff --git a/socpowerbuddy_swift/helper.swift b/SensorUtil/helper.swift similarity index 88% rename from socpowerbuddy_swift/helper.swift rename to SensorUtil/helper.swift index e8a7ccd..dcc0809 100644 --- a/socpowerbuddy_swift/helper.swift +++ b/SensorUtil/helper.swift @@ -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 -} diff --git a/socpowerbuddy_swift/reader.swift b/SensorUtil/reader.swift similarity index 100% rename from socpowerbuddy_swift/reader.swift rename to SensorUtil/reader.swift diff --git a/socpowerbuddy_swift/readers.m b/SensorUtil/readers.m similarity index 100% rename from socpowerbuddy_swift/readers.m rename to SensorUtil/readers.m diff --git a/socpowerbuddy_swift/readers.swift b/SensorUtil/readers.swift similarity index 100% rename from socpowerbuddy_swift/readers.swift rename to SensorUtil/readers.swift diff --git a/socpowerbuddy_swift/smc.swift b/SensorUtil/smc.swift similarity index 100% rename from socpowerbuddy_swift/smc.swift rename to SensorUtil/smc.swift diff --git a/socpowerbuddy_swift/values.swift b/SensorUtil/values.swift similarity index 100% rename from socpowerbuddy_swift/values.swift rename to SensorUtil/values.swift