Mercurial Hosting > luan
changeset 745:9c1f28b26395
a uri can now write another uri which copies the content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 13 Jul 2016 21:27:23 -0600 |
parents | 4b8695f1cfc4 |
children | 293c397e8dee |
files | core/src/luan/modules/IoLuan.java |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/core/src/luan/modules/IoLuan.java Wed Jul 13 20:39:08 2016 -0600 +++ b/core/src/luan/modules/IoLuan.java Wed Jul 13 21:27:23 2016 -0600 @@ -288,7 +288,20 @@ out.close(); return; } - throw new LuanException( "bad argument #1 to 'write' (string or binary expected)" ); + if( obj instanceof LuanTable ) { + LuanTable t = (LuanTable)obj; + Object java = t.rawGet("java"); + if( java instanceof LuanIn ) { + LuanIn luanIn = (LuanIn)java; + InputStream in = luanIn.inputStream(); + OutputStream out = outputStream(); + Utils.copyAll(in,out); + out.close(); + in.close(); + return; + } + } + throw new LuanException( "bad argument #1 to 'write' (string or binary or Io.uri expected)" ); } public LuanTable text_writer() throws IOException {