remove io.files.unique.backend

rename (make-unique-file) to touch-unique-file
db4
Doug Coleman 2008-12-08 21:32:36 -06:00
parent 101bc66b2b
commit 154bc260c6
4 changed files with 22 additions and 20 deletions

View File

@ -1,5 +0,0 @@
USING: io.backend ;
IN: io.files.unique.backend
HOOK: (make-unique-file) io-backend ( path -- )
HOOK: temporary-path io-backend ( -- path )

View File

@ -1,11 +1,13 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math math.bitwise math.parser
random sequences continuations namespaces
io.files io arrays io.files.unique.backend system
combinators vocabs.loader fry ;
USING: kernel math math.bitwise math.parser random sequences
continuations namespaces io.files io arrays system
combinators vocabs.loader fry io.backend ;
IN: io.files.unique
HOOK: touch-unique-file io-backend ( path -- )
HOOK: temporary-path io-backend ( -- path )
SYMBOL: unique-length
SYMBOL: unique-retries
@ -26,12 +28,17 @@ SYMBOL: unique-retries
PRIVATE>
: (make-unique-file) ( path prefix suffix -- path )
'[
_ _ _ unique-length get random-name glue append-path
dup touch-unique-file
] unique-retries get retry ;
: make-unique-file ( prefix suffix -- path )
temporary-path -rot
[
unique-length get random-name glue append-path
dup (make-unique-file)
] 3curry unique-retries get retry ;
[ temporary-path ] 2dip (make-unique-file) ;
: make-unique-file* ( prefix suffix -- path )
[ current-directory get ] 2dip (make-unique-file) ;
: with-unique-file ( prefix suffix quot: ( path -- ) -- )
[ make-unique-file ] dip [ delete-file ] bi ; inline

View File

@ -1,13 +1,13 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel io.ports io.unix.backend math.bitwise
unix io.files.unique.backend system ;
unix system io.files.unique ;
IN: io.unix.files.unique
: open-unique-flags ( -- flags )
{ O_RDWR O_CREAT O_EXCL } flags ;
M: unix (make-unique-file) ( path -- )
M: unix touch-unique-file ( path -- )
open-unique-flags file-mode open-file close-file ;
M: unix temporary-path ( -- path ) "/tmp" ;

View File

@ -1,9 +1,9 @@
USING: kernel system io.files.unique.backend
windows.kernel32 io.windows io.windows.files io.ports windows
destructors environment ;
USING: kernel system windows.kernel32 io.windows
io.windows.files io.ports windows destructors environment
io.files.unique ;
IN: io.windows.files.unique
M: windows (make-unique-file) ( path -- )
M: windows touch-unique-file ( path -- )
GENERIC_WRITE CREATE_NEW 0 open-file dispose ;
M: windows temporary-path ( -- path )