comparison src/luan/lib/OsLib.java @ 147:cc3a0578edac

fix Io.reverse_pickle git-svn-id: https://luan-java.googlecode.com/svn/trunk@148 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Sun, 15 Jun 2014 15:41:36 +0000
parents 0517a4a7fcc5
children 138b9baee80b
comparison
equal deleted inserted replaced
146:0517a4a7fcc5 147:cc3a0578edac
43 43
44 public LuanTable io_file() { 44 public LuanTable io_file() {
45 return new IoLib.LuanFile(file).table(); 45 return new IoLib.LuanFile(file).table();
46 } 46 }
47 47
48 public LuanTable list_children() { 48 public LuanTable children() {
49 File[] files = file.listFiles(); 49 File[] files = file.listFiles();
50 if( files==null ) 50 if( files==null )
51 return null; 51 return null;
52 LuanTable list = new LuanTable(); 52 LuanTable list = new LuanTable();
53 for( File f : files ) { 53 for( File f : files ) {
57 } 57 }
58 58
59 LuanTable table() { 59 LuanTable table() {
60 LuanTable tbl = new LuanTable(); 60 LuanTable tbl = new LuanTable();
61 try { 61 try {
62 tbl.put( "to_string", new LuanJavaFunction(
63 File.class.getMethod( "toString" ), file
64 ) );
62 tbl.put( "name", new LuanJavaFunction( 65 tbl.put( "name", new LuanJavaFunction(
63 File.class.getMethod( "toString" ), file 66 File.class.getMethod( "getName" ), file
64 ) ); 67 ) );
65 tbl.put( "exists", new LuanJavaFunction( 68 tbl.put( "exists", new LuanJavaFunction(
66 File.class.getMethod( "exists" ), file 69 File.class.getMethod( "exists" ), file
67 ) ); 70 ) );
68 tbl.put( "is_directory", new LuanJavaFunction( 71 tbl.put( "is_directory", new LuanJavaFunction(
87 LuanFile.class.getMethod( "child", String.class ), this 90 LuanFile.class.getMethod( "child", String.class ), this
88 ) ); 91 ) );
89 tbl.put( "io_file", new LuanJavaFunction( 92 tbl.put( "io_file", new LuanJavaFunction(
90 LuanFile.class.getMethod( "io_file" ), this 93 LuanFile.class.getMethod( "io_file" ), this
91 ) ); 94 ) );
92 tbl.put( "list_children", new LuanJavaFunction( 95 tbl.put( "children", new LuanJavaFunction(
93 LuanFile.class.getMethod( "list_children" ), this 96 LuanFile.class.getMethod( "children" ), this
94 ) ); 97 ) );
95 } catch(NoSuchMethodException e) { 98 } catch(NoSuchMethodException e) {
96 throw new RuntimeException(e); 99 throw new RuntimeException(e);
97 } 100 }
98 return tbl; 101 return tbl;