From a20f12005a88eed952142990c3f35e63f711d328 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 18 Jun 2012 12:22:59 -0700 Subject: [PATCH] io.files.temp: adding with-temp-directory and with-cache-directory. --- basis/io/files/temp/temp-docs.factor | 7 ++++--- basis/io/files/temp/temp.factor | 9 ++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/basis/io/files/temp/temp-docs.factor b/basis/io/files/temp/temp-docs.factor index 92b75a7e54..fbae04cdcd 100644 --- a/basis/io/files/temp/temp-docs.factor +++ b/basis/io/files/temp/temp-docs.factor @@ -4,14 +4,15 @@ IN: io.files.temp ARTICLE: "io.files.temp" "Temporary files" "Pathnames relative to the system's temporary file directory:" { $subsections - temp-directory temp-file + temp-directory + with-temp-directory } "Pathnames relative to Factor's cache directory, used to store persistent intermediate files and resources:" { $subsections - cache-directory cache-file + cache-directory + with-cache-directory } ; - ABOUT: "io.files.temp" diff --git a/basis/io/files/temp/temp.factor b/basis/io/files/temp/temp.factor index f353d3151f..9693223da9 100644 --- a/basis/io/files/temp/temp.factor +++ b/basis/io/files/temp/temp.factor @@ -1,5 +1,6 @@ ! (c)2012 Joe Groff bsd license -USING: combinators io.pathnames kernel system vocabs ; +USING: combinators io.directories io.pathnames kernel system +vocabs ; IN: io.files.temp HOOK: temp-directory os ( -- path ) @@ -8,9 +9,15 @@ HOOK: cache-directory os ( -- path ) : temp-file ( name -- path ) temp-directory prepend-path ; +: with-temp-directory ( quot -- ) + [ temp-directory ] dip with-directory ; inline + : cache-file ( name -- path ) cache-directory prepend-path ; +: with-cache-directory ( quot -- ) + [ cache-directory ] dip with-directory ; inline + { { [ os windows? ] [ "io.files.temp.windows" ] } { [ os macosx? ] [ "io.files.temp.macosx" ] }