Skip to content

Commit

Permalink
tar: cleanup stack effects, make read-data-blocks recursive.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Nov 2, 2014
1 parent d31d836 commit eb3ca17
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions extra/tar/tar.factor
Expand Up @@ -25,7 +25,7 @@ ERROR: checksum-error header ;
: read-c-string ( n -- str )
read [ zero? ] trim-tail "" like ;

: read-tar-header ( -- tar-header )
: read-tar-header ( -- header )
tar-header new
100 read-c-string >>name
8 read-c-string trim-string oct> >>mode
Expand All @@ -47,7 +47,7 @@ ERROR: checksum-error header ;
TYPED: checksum-header ( seq: byte-array -- n )
148 cut-slice 8 tail-slice [ 0 [ + ] reduce ] bi@ + 256 + >fixnum ;

: read-data-blocks ( tar-header -- )
: read-data-blocks ( header -- )
dup size>> 0 > [
block-size read [
over size>> dup block-size <= [
Expand All @@ -62,9 +62,9 @@ TYPED: checksum-header ( seq: byte-array -- n )
] if*
] [
drop
] if ;
] if ; inline recursive

: parse-tar-header ( seq -- obj )
: parse-tar-header ( seq -- header )
dup checksum-header dup zero-checksum = [
2drop
tar-header new
Expand All @@ -79,10 +79,10 @@ TYPED: checksum-header ( seq: byte-array -- n )

ERROR: unknown-typeflag ch ;

M: unknown-typeflag summary ( obj -- str )
M: unknown-typeflag summary
ch>> [ "Unknown typeflag: " ] dip prefix ;

: read/write-blocks ( tar-header path -- )
: read/write-blocks ( header path -- )
binary [ read-data-blocks ] with-file-writer ;

: prepend-current-directory ( path -- path' )
Expand Down

0 comments on commit eb3ca17

Please sign in to comment.