]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/io/directories/directories.factor
use reject instead of [ ... not ] filter.
[factor.git] / basis / io / directories / directories.factor
index 337a3d2840b7bd1acef519003cd1e0a4cb825de2..eee03c78520e5e0491c406fc120a771df02918e4 100644 (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 -- )
@@ -12,6 +11,9 @@ IN: io.directories
 : with-directory ( path quot -- )
     [ absolute-path current-directory ] dip with-variable ; inline
 
+: with-resource-directory ( quot -- )
+    [ "resource:" ] dip with-directory ; inline
+
 ! Creating directories
 HOOK: make-directory io-backend ( path -- )
 
@@ -29,14 +31,14 @@ HOOK: make-directory io-backend ( path -- )
 ! Listing directories
 TUPLE: directory-entry name type ;
 
-HOOK: >directory-entry os ( byte-array -- directory-entry )
+C: <directory-entry> directory-entry
 
 HOOK: (directory-entries) os ( path -- seq )
 
 : directory-entries ( path -- seq )
     normalize-path
     (directory-entries)
-    [ name>> { "." ".." } member? not ] filter ;
+    [ name>> { "." ".." } member? ] reject ;
 
 : directory-files ( path -- seq )
     directory-entries [ name>> ] map! ;
@@ -55,6 +57,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 ;
 
@@ -65,7 +70,7 @@ HOOK: move-file io-backend ( from to -- )
     to-directory move-file ;
 
 : move-files-into ( files to -- )
-    to-directory '[ _ move-file ] each ;
+    '[ _ move-file-into ] each ;
 
 ! Copying files
 HOOK: copy-file io-backend ( from to -- )
@@ -82,7 +87,7 @@ M: object copy-file
     to-directory copy-file ;
 
 : copy-files-into ( files to -- )
-    to-directory '[ _ copy-file ] each ;
+    '[ _ copy-file-into ] each ;
 
 {
     { [ os unix? ] [ "io.directories.unix" require ] }