Mercurial Hosting > luan
diff core/src/luan/modules/IoLuan.java @ 748:de2418d11786
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 14 Jul 2016 21:09:55 -0600 |
parents | d3a1e9a48a94 |
children | 85f5444fb7d4 |
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);