Nicolas Cannasse 1 vuosi sitten
vanhempi
commit
935ed02400
2 muutettua tiedostoa jossa 15 lisäystä ja 8 poistoa
  1. 4 0
      hxd/fs/Convert.hx
  2. 11 8
      hxd/fs/FileConverter.hx

+ 4 - 0
hxd/fs/Convert.hx

@@ -16,6 +16,10 @@ class Convert {
 	public var dstPath:String;
 	public var originalFilename:String;
 	public var srcBytes:haxe.io.Bytes;
+	/*
+		The calculated hash for the input source file content.
+	*/
+	public var hash : String;
 
 	public function new(sourceExts, destExt) {
 		this.sourceExts = sourceExts == null ? null : sourceExts.split(",");

+ 11 - 8
hxd/fs/FileConverter.hx

@@ -332,19 +332,14 @@ class FileConverter {
 		conv.srcBytes = content;
 		conv.originalFilename = e.name;
 		conv.params = params;
+		conv.hash = hash;
 		onConvert(conv);
-		var prev = hxd.System.allowTimeout;
-		hxd.System.allowTimeout = false;
-		conv.convert();
-		if( prev ) hxd.System.timeoutTick();
-		hxd.System.allowTimeout = prev;
+		executeConvert(conv);
+		conv.hash = null;
 		conv.srcPath = null;
 		conv.dstPath = null;
 		conv.srcBytes = null;
 		conv.originalFilename = null;
-		#if !macro
-		hxd.System.timeoutTick();
-		#end
 
 		if( !sys.FileSystem.exists(fullOutPath) )
 			throw "Converted output file "+fullOutPath+" was not created";
@@ -355,6 +350,14 @@ class FileConverter {
 		saveCache();
 	}
 
+	dynamic function executeConvert( conv : Convert ) {
+		var prev = hxd.System.allowTimeout;
+		hxd.System.allowTimeout = false;
+		conv.convert();
+		if( prev ) hxd.System.timeoutTick();
+		hxd.System.allowTimeout = prev;
+	}
+
 }
 
 #end