changeset 752:ea5f3a254b76

improve file mkdir()
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 15 Jul 2016 16:18:22 -0600
parents 558740169005
children 5e3970ccd86a
files core/src/luan/modules/IoLuan.java
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
diff -r 558740169005 -r ea5f3a254b76 core/src/luan/modules/IoLuan.java
--- a/core/src/luan/modules/IoLuan.java	Fri Jul 15 15:56:19 2016 -0600
+++ b/core/src/luan/modules/IoLuan.java	Fri Jul 15 16:18:22 2016 -0600
@@ -564,6 +564,13 @@
 				throw new LuanException("couldn't delete file "+file);
 		}
 
+		public void mkdir() throws LuanException {
+			if( !file.isDirectory() ) {
+				if( !file.mkdirs() )
+					throw new LuanException("couldn't make directory "+file);
+			}
+		}
+
 		@Override public LuanTable table() {
 			LuanTable tbl = super.table();
 			try {
@@ -580,10 +587,7 @@
 					LuanFile.class.getMethod( "delete" ), this
 				) );
 				tbl.rawPut( "mkdir", new LuanJavaFunction(
-					File.class.getMethod( "mkdir" ), file
-				) );
-				tbl.rawPut( "mkdirs", new LuanJavaFunction(
-					File.class.getMethod( "mkdirs" ), file
+					LuanFile.class.getMethod( "mkdir" ), this
 				) );
 				tbl.rawPut( "last_modified", new LuanJavaFunction(
 					File.class.getMethod( "lastModified" ), file