diff core/src/luan/modules/PackageLuan.java @ 260:f1f7d8c7e94e

add Io.protocols git-svn-id: https://luan-java.googlecode.com/svn/trunk@261 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 28 Oct 2014 23:25:13 +0000
parents f9b201530b85
children 9e0d4452e649
line wrap: on
line diff
--- a/core/src/luan/modules/PackageLuan.java	Tue Oct 28 21:20:48 2014 +0000
+++ b/core/src/luan/modules/PackageLuan.java	Tue Oct 28 23:25:13 2014 +0000
@@ -27,7 +27,7 @@
 				module.put("require",requireFn);
 				add( module, "load", LuanState.class, String.class );
 				add( module, "load_lib", LuanState.class, String.class );
-				add( module, "search_path", String.class, String.class );
+				add( module, "search_path", LuanState.class, String.class, String.class );
 				add( module, "search", LuanState.class, String.class );
 			} catch(NoSuchMethodException e) {
 				throw new RuntimeException(e);
@@ -116,10 +116,10 @@
 		return null;
 	}
 
-	public static String search_path(String name,String path) {
+	public static String search_path(LuanState luan,String name,String path) throws LuanException {
 		for( String s : path.split(";") ) {
 			String file = s.replaceAll("\\?",name);
-			if( Utils.exists(file) )
+			if( file.indexOf(':') > 0 && IoLuan.get(luan,file) != null )
 				return file;
 		}
 		return null;
@@ -134,12 +134,12 @@
 	};
 
 	public static final LuanFunction fileSearcher = new LuanFunction() {
-		@Override public Object[] call(LuanState luan,Object[] args) {
+		@Override public Object[] call(LuanState luan,Object[] args) throws LuanException {
 			String modName = (String)args[0];
 			String path = (String)pkg(luan,"path");
 			if( path==null )
 				return LuanFunction.NOTHING;
-			String file = search_path(modName,path);
+			String file = search_path(luan,modName,path);
 			return file==null ? LuanFunction.NOTHING : new Object[]{fileLoader,file};
 		}
 	};