io.files.unique: some cleanup.

locals-and-roots
John Benediktsson 2016-03-18 16:54:02 -07:00
parent 6f9ff8813e
commit e36727db23
2 changed files with 10 additions and 17 deletions

View File

@ -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

View File

@ -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