diff src/luan/modules/IoLuan.java @ 1497:f04bfbb08721

link_from
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 08 May 2020 16:54:30 -0600
parents 471ef3e6a84e
children 22e15cf73040
line wrap: on
line diff
--- a/src/luan/modules/IoLuan.java	Fri May 08 10:46:13 2020 -0600
+++ b/src/luan/modules/IoLuan.java	Fri May 08 16:54:30 2020 -0600
@@ -25,7 +25,6 @@
 import java.net.NetworkInterface;
 import java.net.MalformedURLException;
 import java.net.UnknownHostException;
-import java.nio.file.Files;
 import java.util.Enumeration;
 import java.util.Map;
 import javax.naming.NamingException;
@@ -464,18 +463,18 @@
 			IoUtils.move(file,dest);
 		}
 
-		public void link_to(Luan luan,Object destObj) throws LuanException, IOException {
-			File dest = objToFile(luan,destObj);
-			if( dest==null )
-				throw new LuanException( "bad argument #1 to 'link_to' (string or file table expected)" );
-			Files.createLink( file.toPath(), dest.toPath() );
+		public void link_from(Luan luan,Object linkObj) throws LuanException, IOException {
+			File link = objToFile(luan,linkObj);
+			if( link==null )
+				throw new LuanException( "bad argument #1 to 'link_from' (string or file table expected)" );
+			IoUtils.link(file,link);
 		}
 
-		public void symlink_to(Luan luan,Object destObj) throws LuanException, IOException {
-			File dest = objToFile(luan,destObj);
-			if( dest==null )
-				throw new LuanException( "bad argument #1 to 'symlink_to' (string or file table expected)" );
-			Files.createSymbolicLink( file.toPath(), dest.toPath() );
+		public void symlink_from(Luan luan,Object linkObj) throws LuanException, IOException {
+			File link = objToFile(luan,linkObj);
+			if( link==null )
+				throw new LuanException( "bad argument #1 to 'symlink_from' (string or file table expected)" );
+			IoUtils.symlink(file,link);
 		}
 
 		public LuanFile canonical(Luan luan) throws LuanException, IOException {