Skip to content

Commit

Permalink
add symbolic link to archive.fs
Browse files Browse the repository at this point in the history
  • Loading branch information
forthy42 committed Jul 20, 2016
1 parent 1370df5 commit c4d6880
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions archive.fs
Expand Up @@ -35,7 +35,11 @@
\ 'h' for hardlink
\ rules for directories are: Specify each before first use

require unix/filestat.fs
require unix/libc.fs

4 buffer: fsize
file-stat buffer: statbuf

: .len ( n -- ) fsize le-l! fsize 4 type ;
: .z ( -- ) 0 .len ;
Expand All @@ -62,9 +66,14 @@ wordlist constant dirs
drop 2drop
THEN ;

: ?symlink ( addr u -- flag )
statbuf lstat ?ior statbuf st_mode w@ S_IFMT and S_IFLNK = ;

: dump-a-file ( addr u -- )
2dup ?dir 2dup + 1- c@ '/' = ?EXIT 'f' .entry
slurp-file dup .len 2dup type drop free throw ;
2dup ?dir 2dup + 1- c@ '/' = ?EXIT
2dup ?symlink IF 's' .entry pad $200 readlink dup ?ior
pad swap dup .len type EXIT THEN
'f' .entry slurp-file dup .len 2dup type drop free throw ;

: dump-files ( -- )
BEGIN argc @ 1 > WHILE
Expand Down

0 comments on commit c4d6880

Please sign in to comment.