]> gitweb.factorcode.org Git - factor.git/commitdiff
fix finding files
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 16 Jan 2009 18:34:59 +0000 (12:34 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 16 Jan 2009 18:34:59 +0000 (12:34 -0600)
basis/io/directories/search/search-docs.factor
basis/io/directories/search/search.factor
basis/windows/shell32/shell32.factor

index 359f1796bb08bd45b1f27cbcf53552ea61c39eb4..8944f17dfffd5c69bf6391cf78152b38a83e474a 100644 (file)
@@ -32,21 +32,21 @@ HELP: find-file
 HELP: find-in-directories
 { $values
      { "directories" "a sequence of pathnames" } { "bfs?" "a boolean, breadth-first or depth-first" } { "quot" quotation }
-     { "path'" "a pathname string" }
+     { "path'/f" "a pathname string or f" }
 }
 { $description "Finds the first file in the input directories matching the predicate quotation in a breadth-first or depth-first traversal." } ;
 
 HELP: find-all-files
 { $values
      { "path" "a pathname string" } { "bfs?" "a boolean, breadth-first or depth-first" } { "quot" quotation }
-     { "paths" "a sequence of pathname strings" }
+     { "paths/f" "a sequence of pathname strings or f" }
 }
 { $description "Finds all files in the input directory matching the predicate quotation in a breadth-first or depth-first traversal." } ;
 
 HELP: find-all-in-directories
 { $values
      { "directories" "a sequence of directory paths" } { "bfs?" "a boolean, breadth-first or depth-first" } { "quot" quotation }
-     { "paths" "a sequence of pathname strings" }
+     { "paths/f" "a sequence of pathname strings or f" }
 }
 { $description "Finds all files in the input directories matching the predicate quotation in a breadth-first or depth-first traversal." } ;
 
index f9a0a14d0c3b781773fde8e2e3af26c9bfad7fbc..41031f8ac38c3272b2ebe53ec1aa47588b62ed80 100755 (executable)
@@ -46,17 +46,21 @@ PRIVATE>
     [ ] accumulator [ each-file ] dip ;
 
 : find-file ( path bfs? quot: ( obj -- ? ) -- path/f )
-    [ <directory-iterator> ] dip
-    [ keep and ] curry iterate-directory ; inline
+    '[
+        _ _ _ [ <directory-iterator> ] dip
+        [ keep and ] curry iterate-directory
+    ] [ drop f ] recover ; inline
 
-: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths )
-    [ <directory-iterator> ] dip
-    pusher [ [ f ] compose iterate-directory drop ] dip ; inline
+: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths/f )
+    '[
+        _ _ _ [ <directory-iterator> ] dip
+        pusher [ [ f ] compose iterate-directory drop ] dip
+    ] [ drop f ] recover ; inline
 
-: find-in-directories ( directories bfs? quot: ( obj -- ? ) -- path' )
+: find-in-directories ( directories bfs? quot: ( obj -- ? ) -- path'/f )
     '[ _ _ find-file ] attempt-all ;
 
-: find-all-in-directories ( directories bfs? quot: ( obj -- ? ) -- paths )
+: find-all-in-directories ( directories bfs? quot: ( obj -- ? ) -- paths/f )
     '[ _ _ find-all-files ] map concat ;
 
 os windows? [ "io.directories.search.windows" require ] when
index b8e6d2c2b0ea0593753fbe6e9206ba52b0ce07ea..acb0cd279b96f7cfdf940f08cfba568dc0a632a1 100644 (file)
@@ -94,7 +94,7 @@ ALIAS: ShellExecute ShellExecuteW
 : shell32-directory ( n -- str )
     f swap f SHGFP_TYPE_DEFAULT
     MAX_UNICODE_PATH "ushort" <c-array>
-    [ SHGetFolderPath shell32-error ] keep utf16n alien>string ;
+    [ SHGetFolderPath drop ] keep utf16n alien>string ;
 
 : desktop ( -- str )
     CSIDL_DESKTOPDIRECTORY shell32-directory ;