Move file-contents word to core/io/io.factor

db4
Aaron Schaefer 2007-12-30 21:29:27 -05:00
parent 8eff6af322
commit 41fa14010d
2 changed files with 20 additions and 21 deletions

View File

@ -1,8 +1,8 @@
! Copyright (C) 2003, 2007 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: hashtables generic kernel math namespaces sequences strings
continuations assocs io.files io.styles sbufs ;
IN: io
USING: hashtables generic kernel math namespaces
sequences strings continuations assocs io.styles sbufs ;
GENERIC: stream-close ( stream -- )
GENERIC: set-timeout ( n stream -- )
@ -90,3 +90,6 @@ SYMBOL: stdio
: contents ( stream -- str )
2048 <sbuf> [ stream-copy ] keep >string ;
: file-contents ( path -- str )
dup <file-reader> swap file-length <sbuf> [ stream-copy ] keep >string ;

View File

@ -1,7 +1,7 @@
! Copyright (C) 2007 Adam Wendt.
! See http://factorcode.org/license.txt for BSD license.
!
USING: alien alien.c-types byte-arrays io io.binary io.files kernel mad namespaces prettyprint sbufs sequences tools.interpreter vars ;
USING: alien alien.c-types byte-arrays io io.binary io.files kernel mad
namespaces prettyprint sbufs sequences tools.interpreter vars ;
IN: mad.api
VARS: buffer-start buffer-length output-callback-var ;
@ -80,11 +80,8 @@ VARS: buffer-start buffer-length output-callback-var ;
: make-decoder ( -- decoder )
"mad_decoder" malloc-object ;
: file-contents ( path -- string )
dup <file-reader> swap file-length <sbuf> [ stream-copy ] keep >byte-array ;
: malloc-file-contents ( path -- alien )
file-contents malloc-byte-array ;
file-contents >byte-array malloc-byte-array ;
: mad-run ( -- int )
make-decoder [ mad-init ] keep MAD_DECODER_MODE_SYNC mad_decoder_run ;
@ -98,4 +95,3 @@ VARS: buffer-start buffer-length output-callback-var ;
: mad-test ( -- results )
[ output-stdout ] >output-callback-var
"/home/adam/download/mp3/Misc/wutbf.mp3" decode-mp3 ;