diff src/luan/modules/IoLuan.java @ 1661:08177ced7fa0

add file.copy_to
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 02 May 2022 18:56:55 -0600
parents c922446f53aa
children d6a50ed9604f
line wrap: on
line diff
--- a/src/luan/modules/IoLuan.java	Tue Apr 19 23:46:06 2022 -0600
+++ b/src/luan/modules/IoLuan.java	Mon May 02 18:56:55 2022 -0600
@@ -453,6 +453,13 @@
 			IoUtils.move(file,dest);
 		}
 
+		public void copy_to(Luan luan,Object destObj) throws LuanException, IOException {
+			File dest = objToFile(luan,destObj);
+			if( dest==null )
+				throw new LuanException( "bad argument #1 to 'rename_to' (string or file table expected)" );
+			IoUtils.copy(file,dest);
+		}
+
 		public void link_from(Luan luan,Object linkObj) throws LuanException, IOException {
 			File link = objToFile(luan,linkObj);
 			if( link==null )