changeset 293:a50e88d3547c

add Web_server.init(); add File.rename_to(); git-svn-id: https://luan-java.googlecode.com/svn/trunk@294 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 11 Dec 2014 01:44:38 +0000
parents e8a2153f6ce1
children 5652cdea25f5
files core/src/luan/modules/IoLuan.java web/src/luan/modules/web/Web_server.luan
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/modules/IoLuan.java	Wed Dec 10 21:44:19 2014 +0000
+++ b/core/src/luan/modules/IoLuan.java	Thu Dec 11 01:44:38 2014 +0000
@@ -404,6 +404,10 @@
 			return file.exists();
 		}
 
+		public boolean rename_to(String dest) {
+			return file.renameTo(new File(dest));
+		}
+
 		@Override LuanTable table() {
 			LuanTable tbl = super.table();
 			try {
@@ -434,6 +438,9 @@
 				tbl.put( "children", new LuanJavaFunction(
 					LuanFile.class.getMethod( "children", LuanState.class ), this
 				) );
+				tbl.put( "rename_to", new LuanJavaFunction(
+					LuanFile.class.getMethod( "rename_to", String.class ), this
+				) );
 			} catch(NoSuchMethodException e) {
 				throw new RuntimeException(e);
 			}
--- a/web/src/luan/modules/web/Web_server.luan	Wed Dec 10 21:44:19 2014 +0000
+++ b/web/src/luan/modules/web/Web_server.luan	Thu Dec 11 01:44:38 2014 +0000
@@ -71,7 +71,7 @@
 function config_server(server)
 end 
 
-function serve(dir)
+function init(dir)
 	dir = dir.gsub("/$","")  -- remove trailing '/' if any
 	Http.dir = dir
 	function Io.schemes.site(path,loading)
@@ -85,6 +85,10 @@
 	resource_handler.setResourceBase(Io.Uri(base).to_string())
 	resource_handler.setWelcomeFiles {welcome_file}
 	luan_handler.setWelcomeFile(welcome_file)
+end
+
+function serve(dir)
+	init(dir)
 	local server = Server.new(port)
 	server.setHandler(hc);
 	config_server(server)