diff core/src/luan/modules/IoLuan.java @ 749:85f5444fb7d4

add rcp lucene backup
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 15 Jul 2016 01:18:01 -0600
parents de2418d11786
children 558740169005
line wrap: on
line diff
--- a/core/src/luan/modules/IoLuan.java	Thu Jul 14 21:09:55 2016 -0600
+++ b/core/src/luan/modules/IoLuan.java	Fri Jul 15 01:18:01 2016 -0600
@@ -542,6 +542,12 @@
 			return new LuanFile(luan,file.getCanonicalFile()).table();
 		}
 
+		public LuanTable create_temp_file(LuanState luan,String prefix,String suffix) throws LuanException, IOException {
+			File tmp = File.createTempFile(prefix,suffix,file);
+			tmp.deleteOnExit();
+			return new LuanFile(luan,tmp).table();
+		}
+
 		@Override public LuanTable table() {
 			LuanTable tbl = super.table();
 			try {
@@ -581,6 +587,9 @@
 				tbl.rawPut( "canonical", new LuanJavaFunction(
 					LuanFile.class.getMethod( "canonical", LuanState.class ), this
 				) );
+				tbl.rawPut( "create_temp_file", new LuanJavaFunction(
+					LuanFile.class.getMethod( "create_temp_file", LuanState.class, String.class, String.class ), this
+				) );
 			} catch(NoSuchMethodException e) {
 				throw new RuntimeException(e);
 			}