Mercurial Hosting > luan
changeset 1497:f04bfbb08721
link_from
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 08 May 2020 16:54:30 -0600 |
parents | 6c830be6be98 |
children | 1b809d2fdf03 |
files | conv.txt src/goodjava/io/IoUtils.java src/luan/modules/Boot.luan src/luan/modules/IoLuan.java |
diffstat | 4 files changed, 20 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/conv.txt Fri May 08 10:46:13 2020 -0600 +++ b/conv.txt Fri May 08 16:54:30 2020 -0600 @@ -1,3 +1,5 @@ +link_to + json_compressed_string literal JsonToString
--- a/src/goodjava/io/IoUtils.java Fri May 08 10:46:13 2020 -0600 +++ b/src/goodjava/io/IoUtils.java Fri May 08 16:54:30 2020 -0600 @@ -31,8 +31,12 @@ delete(file); } - public static void link(File from,File to) throws IOException { - Files.createLink( to.toPath(), from.toPath() ); + public static void link(File existing,File link) throws IOException { + Files.createLink( link.toPath(), existing.toPath() ); + } + + public static void symlink(File existing,File link) throws IOException { + Files.createSymbolicLink( link.toPath(), existing.toPath() ); } public static void copyAll(InputStream in,OutputStream out)
--- a/src/luan/modules/Boot.luan Fri May 08 10:46:13 2020 -0600 +++ b/src/luan/modules/Boot.luan Fri May 08 16:54:30 2020 -0600 @@ -177,8 +177,8 @@ this.set_last_modified = io.set_last_modified this.length = io.file.length this.rename_to = io.rename_to - this.link_to = io.link_to - this.symlink_to = io.symlink_to + this.link_from = io.link_from + this.symlink_from = io.symlink_from this.is_symbolic_link = io.is_symbolic_link function this.child(name)
--- 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 {