Mercurial Hosting > luan
diff core/src/luan/modules/PackageLuan.java @ 265:454a486d9c19
allow IO on files that don't exist
git-svn-id: https://luan-java.googlecode.com/svn/trunk@266 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 29 Oct 2014 16:26:42 +0000 |
parents | 9e0d4452e649 |
children | 1507149fc447 |
line wrap: on
line diff
--- a/core/src/luan/modules/PackageLuan.java Wed Oct 29 03:50:59 2014 +0000 +++ b/core/src/luan/modules/PackageLuan.java Wed Oct 29 16:26:42 2014 +0000 @@ -87,13 +87,19 @@ return mod; } - public static Object[] search(LuanState luan,String modName) throws LuanException { - LuanTable t = IoLuan.get(luan,modName,true); + static LuanFunction loader(LuanState luan,String name,boolean loading) throws LuanException { + LuanTable t = IoLuan.get(luan,name,loading); if( t == null ) return null; LuanFunction loader = (LuanFunction)t.get("loader"); - LuanFunction fn = (LuanFunction)Luan.first(luan.call(loader,new Object[]{modName})); - return new Object[]{fn,modName}; + if( loader == null ) + return null; + return (LuanFunction)Luan.first(luan.call(loader,new Object[]{name})); + } + + public static Object[] search(LuanState luan,String modName) throws LuanException { + LuanFunction fn = loader(luan,modName,true); + return fn==null ? null : new Object[]{fn,modName}; }