Bläddra i källkod

Reload converted file on source changed (#591)

Tom SPIRA 6 år sedan
förälder
incheckning
664d07e88c
1 ändrade filer med 15 tillägg och 1 borttagningar
  1. 15 1
      hxd/fs/LocalFileSystem.hx

+ 15 - 1
hxd/fs/LocalFileSystem.hx

@@ -207,14 +207,25 @@ private class LocalEntry extends FileEntry {
 
 	var watchCallback : Void -> Void;
 	var watchTime : Float;
+	#if (flash && air3)
+	var convertedFile : flash.filesystem.File;
+	#else
+	var convertedFile : String;
+	#end
 	static var WATCH_INDEX = 0;
 	static var WATCH_LIST : Array<LocalEntry> = null;
 	static var tmpDir : String = null;
 
 	inline function getModifTime(){
 		#if flash
+		if (convertedFile != null) {
+			return convertedFile.modificationDate.getTime();
+		}
 		return file.modificationDate.getTime();
 		#else
+		if (convertedFile != null) {
+			return sys.FileSystem.stat(convertedFile).mtime.getTime();
+		}
 		return sys.FileSystem.stat(file).mtime.getTime();
 		#end
 	}
@@ -282,7 +293,7 @@ private class LocalEntry extends FileEntry {
 			WATCH_LIST.push(this);
 		}
 		watchTime = getModifTime();
-		watchCallback = onChanged;
+		watchCallback = function() { fs.convert(this); onChanged(); }
 	}
 
 }
@@ -453,6 +464,9 @@ class LocalFileSystem implements FileSystem {
 		var conv = converts.get(ext);
 		if( conv == null )
 			return;
+		if (e.convertedFile == null) {
+			e.convertedFile = e.file;
+		}
 
 		var path = e.path;
 		var tmpFile = tmpDir + path.substr(0, -ext.length) + conv.destExt;