Move file-contents word to core/io/io.factor
parent
8eff6af322
commit
41fa14010d
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2003, 2007 Slava Pestov.
|
! Copyright (C) 2003, 2007 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! 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
|
IN: io
|
||||||
USING: hashtables generic kernel math namespaces
|
|
||||||
sequences strings continuations assocs io.styles sbufs ;
|
|
||||||
|
|
||||||
GENERIC: stream-close ( stream -- )
|
GENERIC: stream-close ( stream -- )
|
||||||
GENERIC: set-timeout ( n stream -- )
|
GENERIC: set-timeout ( n stream -- )
|
||||||
|
@ -90,3 +90,6 @@ SYMBOL: stdio
|
||||||
|
|
||||||
: contents ( stream -- str )
|
: contents ( stream -- str )
|
||||||
2048 <sbuf> [ stream-copy ] keep >string ;
|
2048 <sbuf> [ stream-copy ] keep >string ;
|
||||||
|
|
||||||
|
: file-contents ( path -- str )
|
||||||
|
dup <file-reader> swap file-length <sbuf> [ stream-copy ] keep >string ;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2007 Adam Wendt.
|
! Copyright (C) 2007 Adam Wendt.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
!
|
USING: alien alien.c-types byte-arrays io io.binary io.files kernel mad
|
||||||
USING: alien alien.c-types byte-arrays io io.binary io.files kernel mad namespaces prettyprint sbufs sequences tools.interpreter vars ;
|
namespaces prettyprint sbufs sequences tools.interpreter vars ;
|
||||||
IN: mad.api
|
IN: mad.api
|
||||||
|
|
||||||
VARS: buffer-start buffer-length output-callback-var ;
|
VARS: buffer-start buffer-length output-callback-var ;
|
||||||
|
@ -80,11 +80,8 @@ VARS: buffer-start buffer-length output-callback-var ;
|
||||||
: make-decoder ( -- decoder )
|
: make-decoder ( -- decoder )
|
||||||
"mad_decoder" malloc-object ;
|
"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 )
|
: malloc-file-contents ( path -- alien )
|
||||||
file-contents malloc-byte-array ;
|
file-contents >byte-array malloc-byte-array ;
|
||||||
|
|
||||||
: mad-run ( -- int )
|
: mad-run ( -- int )
|
||||||
make-decoder [ mad-init ] keep MAD_DECODER_MODE_SYNC mad_decoder_run ;
|
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 )
|
: mad-test ( -- results )
|
||||||
[ output-stdout ] >output-callback-var
|
[ output-stdout ] >output-callback-var
|
||||||
"/home/adam/download/mp3/Misc/wutbf.mp3" decode-mp3 ;
|
"/home/adam/download/mp3/Misc/wutbf.mp3" decode-mp3 ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue