io.directories: defining "?delete-file".

db4
John Benediktsson 2012-10-25 10:07:15 -07:00
parent 33ae7abb23
commit 83712ad87e
3 changed files with 16 additions and 17 deletions

View File

@ -1,9 +1,8 @@
! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays combinators combinators.short-circuit
destructors fry io io.backend io.encodings.binary io.files
io.files.types io.pathnames kernel namespaces sequences
system vocabs vocabs.loader ;
USING: accessors combinators combinators.short-circuit
continuations destructors fry io io.backend io.encodings.binary
io.files io.pathnames kernel namespaces sequences system vocabs ;
IN: io.directories
: set-current-directory ( path -- )
@ -55,6 +54,9 @@ HOOK: delete-file io-backend ( path -- )
HOOK: delete-directory io-backend ( path -- )
: ?delete-file ( path -- )
'[ _ delete-file ] ignore-errors ;
: to-directory ( from to -- from to' )
over file-name append-path ;

View File

@ -1,10 +1,10 @@
! Copyright (C) 2009, 2010 Slava Pestov, Joe Groff.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs io.directories io.encodings.utf8
io.files io.pathnames kernel make math.parser memoize sequences
sets sorting summary vocabs vocabs.loader words system
classes.algebra combinators.short-circuit fry continuations
namespaces ;
USING: accessors arrays assocs classes.algebra
combinators.short-circuit continuations io.directories
io.encodings.utf8 io.files io.pathnames kernel make math.parser
memoize namespaces sequences sets summary system vocabs
vocabs.loader words ;
IN: vocabs.metadata
: check-vocab ( vocab -- vocab )
@ -14,8 +14,6 @@ MEMO: vocab-file-contents ( vocab name -- seq )
vocab-append-path dup
[ dup exists? [ utf8 file-lines ] [ drop f ] if ] when ;
: ?delete-file ( pathname -- ) '[ _ delete-file ] ignore-errors ;
: set-vocab-file-contents ( seq vocab name -- )
dupd vocab-append-path [
swap [ ?delete-file ] [ swap utf8 set-file-lines ] if-empty

View File

@ -1,10 +1,9 @@
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: combinators io io.files io.files.links io.directories
io.pathnames io.streams.string kernel math math.parser
continuations namespaces pack prettyprint sequences strings
system tools.hexdump io.encodings.binary summary accessors
io.backend byte-arrays io.streams.byte-array splitting ;
USING: accessors byte-arrays combinators io io.backend
io.directories io.encodings.binary io.files io.files.links
io.pathnames io.streams.byte-array io.streams.string kernel
math math.parser namespaces sequences strings summary ;
IN: tar
CONSTANT: zero-checksum 256
@ -221,7 +220,7 @@ M: symbolic-link do-link
! FIXME: linux tar calls unlinkat and makelinkat
: make-links ( -- )
to-link get [
[ [ name>> delete-file ] [ 2drop ] recover ] [ do-link ] bi
[ name>> ?delete-file ] [ do-link ] bi
] each ;
: untar ( path -- )