r10071: fix keyword name
[kmrcl.git] / os.lisp
diff --git a/os.lisp b/os.lisp
index 2e524416e83e2d06d620437170fb11f7c8d00907..cce2a2f99fe80f7b221487d08d01ad1f2a20a3c1 100644 (file)
--- a/os.lisp
+++ b/os.lisp
@@ -60,7 +60,8 @@ returns (VALUES string-output error-output exit-status)"
          (let ((status 
                 (system:call-system-showing-output
                  command
-                 :shell-type "/bin/sh"
+                 :prefix ""
+                 :show-cmd nil
                  :output-stream output)))
            (values (get-output-stream-string output) nil status))
        (close output)))
@@ -119,7 +120,9 @@ returns (VALUES output-string pid)"
     (system:call-system-showing-output
      command
      :shell-type "/bin/sh"
-     :output-stream output)
+     :show-cmd nil
+     :prefix ""
+     :output-stream nil)
     
     #+clisp            ;XXX not exactly *verbose-out*, I know
     (ext:run-shell-command  command :output :terminal :wait t)
@@ -135,3 +138,24 @@ returns (VALUES output-string pid)"
     (error "RUN-SHELL-PROGRAM not implemented for this Lisp")
 
     ))
+
+(defun delete-directory-and-files (dir &key (if-does-not-exist :error) (quiet t) force)
+  #+allegro (excl:delete-directory-and-files dir :if-does-not-exist if-does-not-exist
+                                            :quiet quiet :force force)
+  #-(or allegro) (declare (ignore force))
+  #-(or allegro) (cond
+                  ((probe-directory dir)
+                   (let ((cmd (format nil "rm -rf ~A" (namestring dir))))
+                     (unless quiet
+                       (format *trace-output* ";; ~A" cmd))
+                     (command-output cmd)))
+                  ((eq if-does-not-exist :error)
+                   (error "Directory ~A does not exist [delete-directory-and-files]." dir))))
+
+(defun file-size (file)
+  (when (probe-file file)
+    #+allegro (let ((stat (excl.osi:stat (namestring file))))
+               (excl.osi:stat-size stat))
+    #-allegro
+    (with-open-file (in file :direction :input)
+      (file-length in))))