From e36727db23bd5ab5e5e06679be0f5b27e6e71902 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Fri, 18 Mar 2016 16:54:02 -0700 Subject: [PATCH] io.files.unique: some cleanup. --- basis/io/files/unique/unique-tests.factor | 17 ++++++----------- basis/io/files/unique/unique.factor | 10 ++++------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/basis/io/files/unique/unique-tests.factor b/basis/io/files/unique/unique-tests.factor index 95b20bd8cf..108c862088 100644 --- a/basis/io/files/unique/unique-tests.factor +++ b/basis/io/files/unique/unique-tests.factor @@ -1,6 +1,7 @@ -USING: accessors continuations io.directories io.encodings.ascii -io.files io.files.info io.files.unique io.pathnames kernel -namespaces sequences strings tools.test ; +USING: accessors io.directories io.directories.hierarchy +io.encodings.ascii io.files io.files.info io.files.temp +io.files.unique io.pathnames kernel namespaces sequences strings +tools.test ; IN: io.files.unique.tests { 123 } [ @@ -12,13 +13,6 @@ IN: io.files.unique.tests ] with-temp-directory ] unit-test -{ t } [ - [ - [ current-directory get file-info directory? ] - cleanup-unique-directory - ] with-temp-directory -] unit-test - { t } [ [ current-directory get @@ -39,7 +33,8 @@ IN: io.files.unique.tests { t } [ [ - [ ] with-unique-directory >boolean + [ ] with-unique-directory + [ exists? ] [ delete-tree ] bi ] with-temp-directory ] unit-test diff --git a/basis/io/files/unique/unique.factor b/basis/io/files/unique/unique.factor index 2015506e5f..dd9487d5c8 100644 --- a/basis/io/files/unique/unique.factor +++ b/basis/io/files/unique/unique.factor @@ -32,10 +32,9 @@ PRIVATE> : unique-file ( prefix suffix -- path ) '[ - current-directory get - _ _ random-file-name glue append-path + _ _ random-file-name glue dup touch-unique-file - ] unique-retries get retry ; + ] unique-retries get retry absolute-path ; :: cleanup-unique-file ( prefix suffix quot: ( path -- ) -- ) prefix suffix unique-file :> path @@ -43,10 +42,9 @@ PRIVATE> : unique-directory ( -- path ) [ - current-directory get - random-file-name append-path + random-file-name dup make-directory - ] unique-retries get retry ; + ] unique-retries get retry absolute-path ; :: with-unique-directory ( quot -- path ) unique-directory :> path