[armedbear-cvs] r13942 - trunk/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Thu May 24 09:50:35 UTC 2012


Author: mevenson
Date: Thu May 24 02:50:34 2012
New Revision: 13942

Log:
Implement EXT:MAKE-TEMP-DIRECTORY.

Docstrings for MAKE-TEMP-DIRECTORY and MAKE-TEMP-PATHNAME

Adjust the signature of the GENSYM primitive to allow its use in Java
code.  As far as I am concerned, all primitives should be public, as
they constitute the API of the Java part of the implementation.

Modified:
   trunk/abcl/src/org/armedbear/lisp/Extensions.java
   trunk/abcl/src/org/armedbear/lisp/Primitives.java

Modified: trunk/abcl/src/org/armedbear/lisp/Extensions.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Extensions.java	Wed May 23 06:01:06 2012	(r13941)
+++ trunk/abcl/src/org/armedbear/lisp/Extensions.java	Thu May 24 02:50:34 2012	(r13942)
@@ -257,8 +257,9 @@
     }
   }
 
-  // ### make-temp-file => pathname
-  private static final Primitive MAKE_TEMP_FILE = new make_temp_file();
+  public static final Primitive MAKE_TEMP_FILE = new make_temp_file();
+  @DocString(name="make_temp_file",
+             doc="Create and return the pathname of a previously non-existent file.")
   private static class make_temp_file extends Primitive { 
     make_temp_file() {
       super("make-temp-file", PACKAGE_EXT, true, "");
@@ -279,6 +280,32 @@
       return NIL;
     }
   }
+
+  public static final Primitive MAKE_TEMP_DIRECTORY = new make_temp_directory();
+  @DocString(name="make_temp_directory",
+             doc="Create and return the pathname of a previously non-existent directory.")
+  private static class make_temp_directory extends Primitive { 
+    make_temp_directory() {
+      super("make-temp-directory", PACKAGE_EXT, true, "");
+    }
+    @Override
+    public LispObject execute()
+    {
+      try {
+          String tmpdir = System.getProperty("java.io.tmpdir");
+          String name = Primitives.GENSYM.execute().getStringValue();
+          File dir = new File(tmpdir, name);
+          File file = new File(dir, "xx");
+
+          if (file.mkdirs()) {
+            return new Pathname(dir + "/");
+          }
+      } catch (Throwable t) {
+        Debug.trace(t);
+      }
+      return NIL;
+    }
+  }
 
   // ### interrupt-lisp
   private static final Primitive INTERRUPT_LISP = new interrupt_lisp();

Modified: trunk/abcl/src/org/armedbear/lisp/Primitives.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Primitives.java	Wed May 23 06:01:06 2012	(r13941)
+++ trunk/abcl/src/org/armedbear/lisp/Primitives.java	Thu May 24 02:50:34 2012	(r13942)
@@ -3071,7 +3071,7 @@
     };
 
     // ### gensym
-    private static final Primitive GENSYM = new pf_gensym();
+    public static final Primitive GENSYM = new pf_gensym();
     private static final class pf_gensym extends Primitive {
         pf_gensym() {
             super(Symbol.GENSYM, "&optional x");




More information about the armedbear-cvs mailing list