comparison core/src/luan/modules/IoLuan.java @ 310:9e9bb358b2df

add File.canonical() git-svn-id: https://luan-java.googlecode.com/svn/trunk@311 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 23 Dec 2014 07:07:17 +0000
parents a6bf8ff720f8
children 7c4f52262213
comparison
equal deleted inserted replaced
309:6bf47e28e0e5 310:9e9bb358b2df
373 373
374 public boolean rename_to(String dest) { 374 public boolean rename_to(String dest) {
375 return file.renameTo(new File(dest)); 375 return file.renameTo(new File(dest));
376 } 376 }
377 377
378 public LuanTable canonical(LuanState luan) throws LuanException, IOException {
379 return new LuanFile(luan,file.getCanonicalFile()).table();
380 }
381
378 @Override public LuanTable table() { 382 @Override public LuanTable table() {
379 LuanTable tbl = super.table(); 383 LuanTable tbl = super.table();
380 try { 384 try {
381 tbl.put( "name", new LuanJavaFunction( 385 tbl.put( "name", new LuanJavaFunction(
382 File.class.getMethod( "getName" ), file 386 File.class.getMethod( "getName" ), file
405 tbl.put( "children", new LuanJavaFunction( 409 tbl.put( "children", new LuanJavaFunction(
406 LuanFile.class.getMethod( "children", LuanState.class ), this 410 LuanFile.class.getMethod( "children", LuanState.class ), this
407 ) ); 411 ) );
408 tbl.put( "rename_to", new LuanJavaFunction( 412 tbl.put( "rename_to", new LuanJavaFunction(
409 LuanFile.class.getMethod( "rename_to", String.class ), this 413 LuanFile.class.getMethod( "rename_to", String.class ), this
414 ) );
415 tbl.put( "canonical", new LuanJavaFunction(
416 LuanFile.class.getMethod( "canonical", LuanState.class ), this
410 ) ); 417 ) );
411 } catch(NoSuchMethodException e) { 418 } catch(NoSuchMethodException e) {
412 throw new RuntimeException(e); 419 throw new RuntimeException(e);
413 } 420 }
414 return tbl; 421 return tbl;