comparison 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
comparison
equal deleted inserted replaced
1496:6c830be6be98 1497:f04bfbb08721
23 import java.net.InetAddress; 23 import java.net.InetAddress;
24 import java.net.Inet4Address; 24 import java.net.Inet4Address;
25 import java.net.NetworkInterface; 25 import java.net.NetworkInterface;
26 import java.net.MalformedURLException; 26 import java.net.MalformedURLException;
27 import java.net.UnknownHostException; 27 import java.net.UnknownHostException;
28 import java.nio.file.Files;
29 import java.util.Enumeration; 28 import java.util.Enumeration;
30 import java.util.Map; 29 import java.util.Map;
31 import javax.naming.NamingException; 30 import javax.naming.NamingException;
32 import javax.naming.NameNotFoundException; 31 import javax.naming.NameNotFoundException;
33 import javax.naming.directory.Attribute; 32 import javax.naming.directory.Attribute;
462 if( dest==null ) 461 if( dest==null )
463 throw new LuanException( "bad argument #1 to 'rename_to' (string or file table expected)" ); 462 throw new LuanException( "bad argument #1 to 'rename_to' (string or file table expected)" );
464 IoUtils.move(file,dest); 463 IoUtils.move(file,dest);
465 } 464 }
466 465
467 public void link_to(Luan luan,Object destObj) throws LuanException, IOException { 466 public void link_from(Luan luan,Object linkObj) throws LuanException, IOException {
468 File dest = objToFile(luan,destObj); 467 File link = objToFile(luan,linkObj);
469 if( dest==null ) 468 if( link==null )
470 throw new LuanException( "bad argument #1 to 'link_to' (string or file table expected)" ); 469 throw new LuanException( "bad argument #1 to 'link_from' (string or file table expected)" );
471 Files.createLink( file.toPath(), dest.toPath() ); 470 IoUtils.link(file,link);
472 } 471 }
473 472
474 public void symlink_to(Luan luan,Object destObj) throws LuanException, IOException { 473 public void symlink_from(Luan luan,Object linkObj) throws LuanException, IOException {
475 File dest = objToFile(luan,destObj); 474 File link = objToFile(luan,linkObj);
476 if( dest==null ) 475 if( link==null )
477 throw new LuanException( "bad argument #1 to 'symlink_to' (string or file table expected)" ); 476 throw new LuanException( "bad argument #1 to 'symlink_from' (string or file table expected)" );
478 Files.createSymbolicLink( file.toPath(), dest.toPath() ); 477 IoUtils.symlink(file,link);
479 } 478 }
480 479
481 public LuanFile canonical(Luan luan) throws LuanException, IOException { 480 public LuanFile canonical(Luan luan) throws LuanException, IOException {
482 return new LuanFile(luan,file.getCanonicalFile()); 481 return new LuanFile(luan,file.getCanonicalFile());
483 } 482 }