comparison core/src/luan/modules/IoLuan.java @ 752:ea5f3a254b76

improve file mkdir()
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 15 Jul 2016 16:18:22 -0600
parents 558740169005
children ff865e954934
comparison
equal deleted inserted replaced
751:558740169005 752:ea5f3a254b76
562 } 562 }
563 if( !file.delete() ) 563 if( !file.delete() )
564 throw new LuanException("couldn't delete file "+file); 564 throw new LuanException("couldn't delete file "+file);
565 } 565 }
566 566
567 public void mkdir() throws LuanException {
568 if( !file.isDirectory() ) {
569 if( !file.mkdirs() )
570 throw new LuanException("couldn't make directory "+file);
571 }
572 }
573
567 @Override public LuanTable table() { 574 @Override public LuanTable table() {
568 LuanTable tbl = super.table(); 575 LuanTable tbl = super.table();
569 try { 576 try {
570 tbl.rawPut( "name", new LuanJavaFunction( 577 tbl.rawPut( "name", new LuanJavaFunction(
571 File.class.getMethod( "getName" ), file 578 File.class.getMethod( "getName" ), file
578 ) ); 585 ) );
579 tbl.rawPut( "delete", new LuanJavaFunction( 586 tbl.rawPut( "delete", new LuanJavaFunction(
580 LuanFile.class.getMethod( "delete" ), this 587 LuanFile.class.getMethod( "delete" ), this
581 ) ); 588 ) );
582 tbl.rawPut( "mkdir", new LuanJavaFunction( 589 tbl.rawPut( "mkdir", new LuanJavaFunction(
583 File.class.getMethod( "mkdir" ), file 590 LuanFile.class.getMethod( "mkdir" ), this
584 ) );
585 tbl.rawPut( "mkdirs", new LuanJavaFunction(
586 File.class.getMethod( "mkdirs" ), file
587 ) ); 591 ) );
588 tbl.rawPut( "last_modified", new LuanJavaFunction( 592 tbl.rawPut( "last_modified", new LuanJavaFunction(
589 File.class.getMethod( "lastModified" ), file 593 File.class.getMethod( "lastModified" ), file
590 ) ); 594 ) );
591 tbl.rawPut( "child", new LuanJavaFunction( 595 tbl.rawPut( "child", new LuanJavaFunction(