Index: mutils/mutils.scm ================================================================== --- mutils/mutils.scm +++ mutils/mutils.scm @@ -9,25 +9,55 @@ ;; This is from the perl world, a hash of hashes is a super easy way to keep a handle on ;; lots of disparate data ;; +(cond-expand + (chicken-4 + (use sheme chicken)) + (chicken-5 + (import scheme chicken.base))) + (module mutils * - (import chicken scheme - ;; data-structures posix - srfi-1 - ;; srfi-13 - srfi-69 - ports - extras - regex - posix +(import scheme) + +(cond-expand + + (chicken-4 + (import chicken scheme) + (use chicken) + (import posix data-structures - matchable - ) + ports + extras) + (define pseudo-random-integer random) + (define file-writable? file-write-access?)) + + (chicken-5 + (import scheme + chicken.base + chicken.file + chicken.process-context + chicken.process + chicken.port + chicken.io + system-information + chicken.string + chicken.time + chicken.condition + chicken.random + ))) + +(import srfi-1 + ;; srfi-13 + srfi-69 + regex + matchable + sparse-vectors + ) (define (mutils:hierhash-ref hh . keys) (if (null? keys) #f (let loop ((ht hh) @@ -90,12 +120,10 @@ (if (or (string-match comment l) (string-match blank l)) (loop (read-line fh) res) (loop (read-line fh) (cons l res))))))) -(use sparse-vectors) - ;; this is a simple two dimensional sparse array ;; ONLY TWO DIMENSIONS!!! SEE ARRAY-LIB IF YOUR NEEDS ARE GREATER!! ;; (define (mutils:make-sparse-array) @@ -189,12 +217,12 @@ ;;====================================================================== ;; Other utils ;;====================================================================== (define (check-write-create fpath) - (and (file-write-access? fpath) - (let ((fname (conc fpath "/.junk-" (current-seconds) "-" (random 10000)))) + (and (file-writable? fpath) + (let ((fname (conc fpath "/.junk-" (current-seconds) "-" (pseudo-random-integer 10000)))) ;;(print "trying to create/remove " fname) (handle-exceptions exn #f (begin