Publish v1.0
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit

Reviewed-on: #1
This commit is contained in:
2022-10-17 11:24:27 +02:00
parent a99466f258
commit 6203700b0c
87 changed files with 3112 additions and 1223 deletions

View File

@ -15,26 +15,29 @@ public class GeneratorChecker {
return true
}
// If inputFile is newer that generated extension -> Regenerate
let extensionFileURL = URL(fileURLWithPath: extensionFilePath)
let inputFileURL = URL(fileURLWithPath: inputFilePath)
let extensionRessourceValues = try? extensionFileURL.resourceValues(forKeys: [URLResourceKey.contentModificationDateKey])
let inputFileRessourceValues = try? inputFileURL.resourceValues(forKeys: [URLResourceKey.contentModificationDateKey])
if let extensionModificationDate = extensionRessourceValues?.contentModificationDate,
let inputFileModificationDate = inputFileRessourceValues?.contentModificationDate {
if inputFileModificationDate >= extensionModificationDate {
print("Input file is newer that generated extension.")
return true
} else {
return false
}
}
return Self.isFile(inputFilePath, moreRecenThan: extensionFilePath)
}
// ModificationDate not available for both file
print("⚠️ Could not compare file modication date. ⚠️")
return true
public static func isFile(_ fileOne: String, moreRecenThan fileTwo: String) -> Bool {
let fileOneURL = URL(fileURLWithPath: fileOne)
let fileTwoURL = URL(fileURLWithPath: fileTwo)
let fileOneRessourceValues = try? fileOneURL.resourceValues(forKeys: [URLResourceKey.contentModificationDateKey])
let fileTwoRessourceValues = try? fileTwoURL.resourceValues(forKeys: [URLResourceKey.contentModificationDateKey])
guard let fileOneModificationDate = fileOneRessourceValues?.contentModificationDate,
let fileTwoModificationDate = fileTwoRessourceValues?.contentModificationDate else {
print("⚠️ Could not compare file modication date. ⚠️ (assume than file is newer)")
// Date not available -> assume than fileOne is newer than fileTwo
return true
}
if fileOneModificationDate >= fileTwoModificationDate {
debugPrint("File one is more recent than file two.")
return true
}
return false
}
}