Mercurial Hosting > luan
changeset 748:de2418d11786
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 14 Jul 2016 21:09:55 -0600 |
parents | d3a1e9a48a94 |
children | 85f5444fb7d4 |
files | core/src/luan/modules/IoLuan.java lucene/src/luan/modules/lucene/Lucene.luan |
diffstat | 2 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/core/src/luan/modules/IoLuan.java Thu Jul 14 20:03:01 2016 -0600 +++ b/core/src/luan/modules/IoLuan.java Thu Jul 14 21:09:55 2016 -0600 @@ -30,6 +30,7 @@ import java.net.MalformedURLException; import java.net.UnknownHostException; import java.util.Enumeration; +import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -331,11 +332,21 @@ return binaryWriter(new BufferedOutputStream(outputStream())); } - public void zip(LuanState luan,String basePath,String... filePaths) throws LuanException, IOException { - if( filePaths.length == 0 ) { + public void zip(LuanState luan,String basePath,LuanTable filePathList) throws LuanException, IOException { + String[] filePaths; + if( filePathList==null ) { File file = new File(basePath).getCanonicalFile(); filePaths = new String[]{file.toString()}; basePath = file.getParent(); + } else { + List list = filePathList.asList(); + filePaths = new String[list.size()]; + for( int i=0; i<filePaths.length; i++ ) { + Object obj = list.get(i); + if( !(obj instanceof String) ) + throw new LuanException("file paths must be strings"); + filePaths[i] = (String)obj; + } } if( !basePath.endsWith("/") ) basePath += '/'; @@ -379,7 +390,7 @@ LuanIO.class.getMethod( "binary_writer" ), this ) ); tbl.rawPut( "zip", new LuanJavaFunction( - LuanIO.class.getMethod( "zip", LuanState.class, String.class, new String[0].getClass() ), this + LuanIO.class.getMethod( "zip", LuanState.class, String.class, LuanTable.class ), this ) ); } catch(NoSuchMethodException e) { throw new RuntimeException(e);
--- a/lucene/src/luan/modules/lucene/Lucene.luan Thu Jul 14 20:03:01 2016 -0600 +++ b/lucene/src/luan/modules/lucene/Lucene.luan Thu Jul 14 21:09:55 2016 -0600 @@ -8,7 +8,6 @@ local uri = Io.uri or error() local String = require "luan:String.luan" local matches = String.matches or error() -local Table = require "luan:Table.luan" local LuceneIndex = require "java:luan.modules.lucene.LuceneIndex" local NumberFieldParser = require "java:luan.modules.lucene.queryparser.NumberFieldParser" local StringFieldParser = require "java:luan.modules.lucene.queryparser.StringFieldParser" @@ -110,7 +109,7 @@ t[#t+1] = dir.."/"..file_name end local base = uri("file:"..dir).parent().to_string() - uri(zip_file).zip(base,Table.unpack(t)) + uri(zip_file).zip(base,t) end ) end