diff src/luan/modules/PackageLuan.java @ 787:c49980cdece6

use incremental cloning to serve web pages
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 04 Sep 2016 00:18:00 -0600
parents 1a68fc55a80c
children 9eccfede1094
line wrap: on
line diff
--- a/src/luan/modules/PackageLuan.java	Fri Sep 02 17:43:29 2016 -0600
+++ b/src/luan/modules/PackageLuan.java	Sun Sep 04 00:18:00 2016 -0600
@@ -68,12 +68,39 @@
 		LuanTable t = IoLuan.uri(luan,uri,null);
 		if( t == null )
 			return null;
+/*
 		LuanFunction existsFn = (LuanFunction)t.get(luan,"exists");
 		boolean exists = (Boolean)Luan.first(existsFn.call(luan));
 		if( !exists )
 			return null;
 		LuanFunction reader = (LuanFunction)t.get(luan,"read_text");
 		return (String)Luan.first(reader.call(luan));
+*/
+		IoLuan.LuanIn in = (IoLuan.LuanIn)t.rawGet("java");
+		try {
+			if( !in.exists() )
+				return null;
+			return in.read_text();
+		} catch(IOException e) {
+			throw new LuanException(e);
+		}
+	}
+
+	public static boolean wouldLoad(LuanState luan,String modName) throws LuanException {
+		LuanTable loaded = loaded(luan);
+		if( loaded.rawGet(modName) != null )
+			return false;
+		if( modName.startsWith("java:") )
+			return true;
+		LuanTable t = IoLuan.uri(luan,modName,null);
+		if( t == null )
+			return false;
+		IoLuan.LuanIn in = (IoLuan.LuanIn)t.rawGet("java");
+		try {
+			return in.exists();
+		} catch(IOException e) {
+			throw new LuanException(e);
+		}
 	}
 
 }