Mise à jour des headers des fichiers générés
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
40
Sources/ToolCore/GeneratorChecker.swift
Normal file
40
Sources/ToolCore/GeneratorChecker.swift
Normal file
@ -0,0 +1,40 @@
|
||||
//
|
||||
// GeneratorChecker.swift
|
||||
//
|
||||
//
|
||||
// Created by Thibaut Schmitt on 22/12/2021.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public class GeneratorChecker {
|
||||
|
||||
/// Return `true` if inputFile is newer than extensionFile, otherwise `false`
|
||||
public static func shouldGenerate(force: Bool, inputFilePath: String, extensionFilePath: String) -> Bool {
|
||||
guard force == false else {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// ModificationDate not available for both file
|
||||
print("⚠️ Could not compare file modication date. ⚠️")
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user