From a399439a5f49d9e04d34f1bf89d243269e2aa4cb Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 25 May 2016 17:44:13 -0700 Subject: [PATCH] io.files.unique: Make sure the files are the same except for the suffix. Add unit test. Fix paths typo. --- basis/io/files/unique/unique-tests.factor | 8 ++++++++ basis/io/files/unique/unique.factor | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/basis/io/files/unique/unique-tests.factor b/basis/io/files/unique/unique-tests.factor index f71a28f78d..e12600c7a2 100644 --- a/basis/io/files/unique/unique-tests.factor +++ b/basis/io/files/unique/unique-tests.factor @@ -47,3 +47,11 @@ IN: io.files.unique.tests ] with-unique-directory drop ] with-temp-directory ] unit-test + +{ 29 } [ + [ + "unique-files-" { "-test.0" "-test.1" } [ + [ file-name ] map first2 mismatch + ] cleanup-unique-files + ] with-temp-directory +] unit-test \ No newline at end of file diff --git a/basis/io/files/unique/unique.factor b/basis/io/files/unique/unique.factor index 77d5628b15..625dba32b6 100644 --- a/basis/io/files/unique/unique.factor +++ b/basis/io/files/unique/unique.factor @@ -38,8 +38,8 @@ PRIVATE> : unique-files ( prefix suffixes -- paths ) '[ - _ _ [ - random-file-name glue + _ _ random-file-name '[ + _ glue dup touch-unique-file ] with map ] unique-retries get retry [ absolute-path ] map ; @@ -48,7 +48,7 @@ PRIVATE> prefix suffix unique-file :> path [ path quot call ] [ path delete-file ] [ ] cleanup ; inline -:: cleanup-unique-files ( ..a prefix suffixes quot: ( ..a path -- ..b ) -- ..b ) +:: cleanup-unique-files ( ..a prefix suffixes quot: ( ..a paths -- ..b ) -- ..b ) prefix suffixes unique-files :> paths [ paths quot call ] [ paths [ delete-file ] each ] [ ] cleanup ; inline