diff --git a/src/hxp/System.hx b/src/hxp/System.hx index 0e43daf..96bb3a6 100644 --- a/src/hxp/System.hx +++ b/src/hxp/System.hx @@ -22,6 +22,7 @@ class System private static var _hostPlatform:HostPlatform; private static var _isText:Map; private static var _processorCores:Int = 0; + private static var _templates:Array = []; private static function __init__():Void { @@ -201,6 +202,8 @@ class System if (process && context != null) { + _templates.push(destination); + if (_isText.exists(extension) && !_isText.get(extension)) { copyIfNewer(source, destination); @@ -362,6 +365,24 @@ class System catch (e:Dynamic) {} } + public static function deleteStaleTemplates(targetDirectory:String) + { + var templatesFile = Path.combine(targetDirectory, ".templates"); + if (FileSystem.exists(templatesFile)) + { + for (template in File.getContent(templatesFile).split("\n")) + { + if (_templates.indexOf(template) < 0) + { + deleteFile(template); + } + } + } + + File.saveContent(templatesFile, _templates.join("\n")); + _templates.resize(0); + } + private static function findTemplateRecursive_(templatePaths:Array, source:String, templateFiles:Array, templateMatched:Map, destinationPaths:Array):Void {