From 111fa3c8f021c4abffc1526c882fc3eb4e3aa63e Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Fri, 29 Feb 2008 00:22:35 -0800 Subject: [PATCH] Make ensure-dir platform-neutral. --- arc.arc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arc.arc b/arc.arc index f72418c24..64f52d788 100644 --- a/arc.arc +++ b/arc.arc @@ -1212,9 +1212,22 @@ (or (errsafe (load-table filename)) (table))) +(def mkdir (path (o parents)) + ((if parents + (let os (which-os) + (if + ; If we're running Unix, MzScheme <371 has a bug + ; where make-directory* sets the sticky bit. + ; Thus, we want to use system instead. + (or (is os 'unix) (is os 'macosx)) + [system (string "mkdir -p " _)] + ($ (begin (require (lib "file.ss")) make-directory*)))) + ($ make-directory)) + path) + nil) + (def ensure-dir (path) - (unless (dir-exists path) - (system (string "mkdir -p " path)))) + (mkdir path t)) (def pad (val digits (o char #\ )) (= val (string val))