changeset 1470:580ee513a4b7

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 14 Apr 2020 17:12:06 -0600
parents 21f5edab1fbf
children f5b8c7e1ac82
files src/luan/modules/Binary.luan src/luan/modules/Boot.luan src/luan/modules/IoLuan.java
diffstat 3 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/Binary.luan	Tue Apr 14 13:15:18 2020 -0600
+++ b/src/luan/modules/Binary.luan	Tue Apr 14 17:12:06 2020 -0600
@@ -1,9 +1,12 @@
 require "java"
 local BinaryLuan = require "java:luan.modules.BinaryLuan"
+local Base64 = require "java:java.util.Base64"
 
 
 local Binary = {}
 
+Binary.base64_decode = Base64.getDecoder().decode
+Binary.base64_encode = Base64.getEncoder().encode
 Binary.binary = BinaryLuan.binary
 Binary.byte = BinaryLuan.byte_
 Binary.to_string = BinaryLuan.to_string
--- a/src/luan/modules/Boot.luan	Tue Apr 14 13:15:18 2020 -0600
+++ b/src/luan/modules/Boot.luan	Tue Apr 14 17:12:06 2020 -0600
@@ -75,6 +75,7 @@
 	local this = new_LuanIn(io)
 	this.write = io.write
 	this.write_text = io.write_text
+	this.write_binary = io.write_binary
 
 	function this.text_writer()
 		return new_writer( io.text_writer() )
--- a/src/luan/modules/IoLuan.java	Tue Apr 14 13:15:18 2020 -0600
+++ b/src/luan/modules/IoLuan.java	Tue Apr 14 17:12:06 2020 -0600
@@ -301,10 +301,16 @@
 		}
 
 		public void write_text(Object... args) throws LuanException, IOException {
-			LuanWriter luanWriter = luanWriter(new BufferedWriter(writer()));
+			LuanWriter luanWriter = text_writer();
 			luanWriter.write(args);
 			luanWriter.close();
 		}
+
+		public void write_binary(byte[] bytes) throws LuanException, IOException {
+			OutputStream out = binary_writer();
+			out.write(bytes);
+			out.close();
+		}
 	}
 
 	public static final LuanIO nullIO = new LuanIO() {