Skip to content

Commit

Permalink
Merge pull request #92 from matxpa/main
Browse files Browse the repository at this point in the history
Update process changes
  • Loading branch information
0xCUB3 committed May 22, 2024
2 parents 8942d48 + a2597dc commit 2698062
Show file tree
Hide file tree
Showing 7 changed files with 778 additions and 86 deletions.
8 changes: 6 additions & 2 deletions About This Hack.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
58B988D926D7ACD80092EC5B /* ViewControllerStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58B988D626D7ACD70092EC5B /* ViewControllerStorage.swift */; };
58B988DA26D7ACD80092EC5B /* ViewControllerSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58B988D726D7ACD80092EC5B /* ViewControllerSupport.swift */; };
72E686C32862453700B8316D /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72E686C22862453700B8316D /* Reachability.swift */; };
9664A9132BECC81D00B5E306 /* SystemFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9664A9122BECC81D00B5E306 /* SystemFunctions.swift */; };
C1BAD6FF26D70091008460FB /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1BAD6FE26D70091008460FB /* WindowController.swift */; };
C1D8307D2AAE57E500ABD4A4 /* Tooltips.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1D8307C2AAE57E500ABD4A4 /* Tooltips.swift */; };
C1EDE5612AC9E70C00878889 /* InitGlobalVariables.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1EDE5602AC9E70C00878889 /* InitGlobalVariables.swift */; };
Expand Down Expand Up @@ -52,6 +53,7 @@
58B988D726D7ACD80092EC5B /* ViewControllerSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewControllerSupport.swift; sourceTree = "<group>"; };
72E686C22862453700B8316D /* Reachability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = "<group>"; };
965FD7C32AF3947B007E88BC /* fr */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = fr; path = fr.lproj/Main.storyboard; sourceTree = "<group>"; };
9664A9122BECC81D00B5E306 /* SystemFunctions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemFunctions.swift; sourceTree = "<group>"; };
C1BAD6FE26D70091008460FB /* WindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = "<group>"; };
C1D8307C2AAE57E500ABD4A4 /* Tooltips.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tooltips.swift; sourceTree = "<group>"; };
C1EDE5602AC9E70C00878889 /* InitGlobalVariables.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitGlobalVariables.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -122,6 +124,7 @@
58134C0128668FF70008B00D /* Keycodes.swift */,
C1F22EAE2AA4EDE000236BB6 /* UpdateController.swift */,
C1D8307C2AAE57E500ABD4A4 /* Tooltips.swift */,
9664A9122BECC81D00B5E306 /* SystemFunctions.swift */,
);
path = "About This Hack";
sourceTree = "<group>";
Expand Down Expand Up @@ -249,6 +252,7 @@
115D922426D6F6AF00F5DF35 /* InsertExtension.swift in Sources */,
DC68704A2A633DDD00CAD908 /* HCMacModel.swift in Sources */,
115D921226D6F65500F5DF35 /* AppDelegate.swift in Sources */,
9664A9132BECC81D00B5E306 /* SystemFunctions.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -415,7 +419,7 @@
"$(SDKROOT)/usr/lib/swift",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.2.0;
MARKETING_VERSION = 1.1.0;
PRODUCT_BUNDLE_IDENTIFIER = "app.netlify.0xCUBE.About-This-Hack";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -448,7 +452,7 @@
"$(SDKROOT)/usr/lib/swift",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.2.0;
MARKETING_VERSION = 1.1.0;
PRODUCT_BUNDLE_IDENTIFIER = "app.netlify.0xCUBE.About-This-Hack";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
28 changes: 0 additions & 28 deletions About This Hack/HardwareCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,31 +156,3 @@ class HardwareCollector {
""", String(1 - percent)]
}
}


extension String {

var length: Int {
return count
}

subscript (i: Int) -> String {
return self[i ..< i + 1]
}

func substring(fromIndex: Int) -> String {
return self[min(fromIndex, length) ..< length]
}

func substring(toIndex: Int) -> String {
return self[0 ..< max(0, toIndex)]
}

subscript (r: Range<Int>) -> String {
let range = Range(uncheckedBounds: (lower: max(0, min(length, r.lowerBound)),
upper: min(length, max(0, r.upperBound))))
let start = index(startIndex, offsetBy: range.lowerBound)
let end = index(start, offsetBy: range.upperBound - range.lowerBound)
return String(self[start ..< end])
}
}
36 changes: 27 additions & 9 deletions About This Hack/InitGlobalVariables.swift
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
//
// InitGlobalVariables.swift
//

import Foundation
import AppKit

class initGlobVar {


static var thisComponent: String {
return String(describing: self)
}

static var athfilesDirectory = "/.ath"
static var tempDirectory = "/private/tmp" // "/tmp" is equiv.
static var athDirectory = tempDirectory + athfilesDirectory
// static var athDirectory = NSHomeDirectory() + athfilesDirectory
static var defaultfileManager = FileManager.default

// Used by UpdateController
static var lastAthreleaseURL = "https://github.com/0xCUB3/About-This-Hack/releases/download/"
static var athrepositoryURL = "https://github.com/0xCUB3/About-This-Hack"
static var lastAthreleaseURL = athrepositoryURL + "/releases/download/"
static var allAppliLocation = "/Applications"
static var thisAppliname = "/About This Hack.app"
static var thisAppliLocation = allAppliLocation + thisAppliname
static var newAthziprelease = "/About.This.Hack.zip"
static var thisAppliLocation = "\(allAppliLocation)/\(thisApplicationName).app"
static var newAthziprelease = "\(thisApplicationName.replacingOccurrences(of: " ", with: ".")).zip"
static var newAthreleasezip = athDirectory + "/new_ath.zip"
static var athtargetversionfile = athDirectory + "/version.txt"

static var athsourceversionfile = "https://raw.githubusercontent.com/0xCUB3/Website/main/content/ath.txt"
static var athlasttagpbxproj = "/blob/[LASTTAG]/About%20This%20Hack.xcodeproj/project.pbxproj"

// OCLP Dict File (if exists) where Patch Version Commit and DateTime will be extracted
static var oclpXmlFilePath = "/System/Library/CoreServices/OpenCore-Legacy-Patcher.plist"
static var bdmesgExecID = "/usr/local/bin/bdmesg"

// ioreg Dir perl script and pci ids and names files
static var whichLocation = "/usr/bin/which"

// static var sysprofLocation = run(whichLocation + " system_profiler | /usr/bin/tr -d '\n'")
// static var diskutilLocation = run(whichLocation + " diskutil | /usr/bin/tr -d '\n'")
// static var sysctlLocation = run(whichLocation + " sysctl | /usr/bin/tr -d '\n'")
// static var catLocation = run(whichLocation + " cat | /usr/bin/tr -d '\n'")
// static var ioregLocation = run(whichLocation + " ioreg | /usr/bin/tr -d '\n'")
static var curlLocation = run(whichLocation + " curl | /usr/bin/tr -d '\n'")
// static var perlLocation = run(whichLocation + " perl | /usr/bin/tr -d '\n'")

// Files with Overview, Displays and Storage detailed Datas
static var hwFilePath = athDirectory + "/hw.txt"
static var scrFilePath = athDirectory + "/scr.txt"
Expand Down
78 changes: 76 additions & 2 deletions About This Hack/InsertExtension.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
//
// InsertExtension.swift
// InsertExtension
//
//

import Darwin
import Foundation

var myself: String = "Extensions"

extension String {

var length: Int {
return count
}

subscript (i: Int) -> String {
return self[i ..< i + 1]
}

func substring(fromIndex: Int) -> String {
return self[min(fromIndex, length) ..< length]
}

func substring(toIndex: Int) -> String {
return self[0 ..< max(0, toIndex)]
}

subscript (r: Range<Int>) -> String {
let range = Range(uncheckedBounds: (lower: max(0, min(length, r.lowerBound)),
upper: min(length, max(0, r.upperBound))))
let start = index(startIndex, offsetBy: range.lowerBound)
let end = index(start, offsetBy: range.upperBound - range.lowerBound)
return String(self[start ..< end])
}

func inserting(separator: String, every n: Int) -> String {
var result: String = ""
let characters = Array(self)
Expand All @@ -18,4 +44,52 @@ extension String {
}
return result
}

func reverseString(separator: String, every n: Int, removeChars: String, hexencode: String) -> String {

var outValue: String = ""
var workStr: String = self
let nbrSubStr = (workStr.count/n)

if nbrSubStr > 1 {
for _ in 0..<nbrSubStr {
if workStr.suffix(n) != removeChars {
outValue += workStr.suffix(n)
}
workStr = String(workStr.dropLast(2))
}
}
let intValue = outValue
if hexencode.lowercased().starts(with: "y") {
outValue = String(Int(outValue, radix: 16) ?? 0)
}
// print("\(myself) : From Hexa InVal : " + self + " by hexa invert. IntVal : \(intValue) to Dec OutVal : \(outValue)")
return ("\(outValue);\(intValue);\(self)")
}

var isNumber: Bool {
return self.allSatisfy { character in
character.isNumber
}
}

func removedRegexMatches(pattern: String, replaceWith: String = "") -> String {
do {
let regex = try NSRegularExpression(pattern: pattern, options: NSRegularExpression.Options.caseInsensitive)
let range = NSRange(location: 0, length: self.count)
return regex.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: replaceWith)
} catch {
return self
}
}

}

extension Data {

func hexadecimalString() -> String {
self.reduce( "0x" ) {
$0.appending( String( format: "%02X", $1 ) )
}
}
}
Loading

0 comments on commit 2698062

Please sign in to comment.