From 2753b2442af438446b971115f94220a99184c0ea Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 28 Feb 2008 16:37:27 -0600 Subject: [PATCH] fix io.files.temporary for windows --- extra/io/files/temporary/backend/backend.factor | 2 +- extra/io/files/temporary/temporary.factor | 10 +++------- extra/io/windows/files/temporary/temporary.factor | 6 ++++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/extra/io/files/temporary/backend/backend.factor b/extra/io/files/temporary/backend/backend.factor index 0fe4068621..5c6900b3d2 100644 --- a/extra/io/files/temporary/backend/backend.factor +++ b/extra/io/files/temporary/backend/backend.factor @@ -1,5 +1,5 @@ USING: io.backend ; IN: io.files.temporary.backend -HOOK: (temporary-file) io-backend ( path prefix suffix -- stream path ) +HOOK: (temporary-file) io-backend ( path -- stream path ) HOOK: temporary-path io-backend ( -- path ) diff --git a/extra/io/files/temporary/temporary.factor b/extra/io/files/temporary/temporary.factor index d46ddff8c6..5c5e72e83f 100644 --- a/extra/io/files/temporary/temporary.factor +++ b/extra/io/files/temporary/temporary.factor @@ -2,18 +2,14 @@ USING: kernel math math.bitfields combinators.lib math.parser random sequences sequences.lib continuations namespaces io.files io.backend io.nonblocking io arrays io.files.temporary.backend system combinators vocabs.loader ; -USE: tools.walker IN: io.files.temporary -: random-letter ( -- ch ) - 26 random { CHAR: a CHAR: A } random + ; +: random-letter ( -- ch ) 26 random { CHAR: a CHAR: A } random + ; : random-ch ( -- ch ) - { t f } random - [ 10 random CHAR: 0 + ] [ random-letter ] if ; + { t f } random [ 10 random CHAR: 0 + ] [ random-letter ] if ; -: random-name ( n -- string ) - [ drop random-ch ] "" map-as ; +: random-name ( n -- string ) [ drop random-ch ] "" map-as ; : ( prefix suffix -- path duplex-stream ) temporary-path -rot diff --git a/extra/io/windows/files/temporary/temporary.factor b/extra/io/windows/files/temporary/temporary.factor index d96ff49e15..426cab367b 100644 --- a/extra/io/windows/files/temporary/temporary.factor +++ b/extra/io/windows/files/temporary/temporary.factor @@ -1,8 +1,10 @@ -USING: kernel system ; +USING: io.files.temporary.backend io.nonblocking io.windows +kernel system windows.kernel32 ; + IN: io.windows.files.temporary M: windows-io (temporary-file) ( path -- stream ) - GENERIC_WRITE CREATE_NEW 0 open-file 0 ; + GENERIC_WRITE CREATE_NEW 0 open-file 0 ; M: windows-io temporary-path ( -- path ) "TEMP" os-env ;