comparison 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
comparison
equal deleted inserted replaced
786:fe63c508a177 787:c49980cdece6
66 66
67 static String read(LuanState luan,String uri) throws LuanException { 67 static String read(LuanState luan,String uri) throws LuanException {
68 LuanTable t = IoLuan.uri(luan,uri,null); 68 LuanTable t = IoLuan.uri(luan,uri,null);
69 if( t == null ) 69 if( t == null )
70 return null; 70 return null;
71 /*
71 LuanFunction existsFn = (LuanFunction)t.get(luan,"exists"); 72 LuanFunction existsFn = (LuanFunction)t.get(luan,"exists");
72 boolean exists = (Boolean)Luan.first(existsFn.call(luan)); 73 boolean exists = (Boolean)Luan.first(existsFn.call(luan));
73 if( !exists ) 74 if( !exists )
74 return null; 75 return null;
75 LuanFunction reader = (LuanFunction)t.get(luan,"read_text"); 76 LuanFunction reader = (LuanFunction)t.get(luan,"read_text");
76 return (String)Luan.first(reader.call(luan)); 77 return (String)Luan.first(reader.call(luan));
78 */
79 IoLuan.LuanIn in = (IoLuan.LuanIn)t.rawGet("java");
80 try {
81 if( !in.exists() )
82 return null;
83 return in.read_text();
84 } catch(IOException e) {
85 throw new LuanException(e);
86 }
87 }
88
89 public static boolean wouldLoad(LuanState luan,String modName) throws LuanException {
90 LuanTable loaded = loaded(luan);
91 if( loaded.rawGet(modName) != null )
92 return false;
93 if( modName.startsWith("java:") )
94 return true;
95 LuanTable t = IoLuan.uri(luan,modName,null);
96 if( t == null )
97 return false;
98 IoLuan.LuanIn in = (IoLuan.LuanIn)t.rawGet("java");
99 try {
100 return in.exists();
101 } catch(IOException e) {
102 throw new LuanException(e);
103 }
77 } 104 }
78 105
79 } 106 }