From 4e7298cfa4b1b0e5b40b882ef51e8cd8f9ba5f4c Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 16 Jan 2009 12:34:59 -0600 Subject: [PATCH] fix finding files --- basis/io/directories/search/search-docs.factor | 6 +++--- basis/io/directories/search/search.factor | 18 +++++++++++------- basis/windows/shell32/shell32.factor | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/basis/io/directories/search/search-docs.factor b/basis/io/directories/search/search-docs.factor index 359f1796bb..8944f17dff 100644 --- a/basis/io/directories/search/search-docs.factor +++ b/basis/io/directories/search/search-docs.factor @@ -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." } ; diff --git a/basis/io/directories/search/search.factor b/basis/io/directories/search/search.factor index f9a0a14d0c..41031f8ac3 100755 --- a/basis/io/directories/search/search.factor +++ b/basis/io/directories/search/search.factor @@ -46,17 +46,21 @@ PRIVATE> [ ] accumulator [ each-file ] dip ; : find-file ( path bfs? quot: ( obj -- ? ) -- path/f ) - [ ] dip - [ keep and ] curry iterate-directory ; inline + '[ + _ _ _ [ ] dip + [ keep and ] curry iterate-directory + ] [ drop f ] recover ; inline -: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths ) - [ ] dip - pusher [ [ f ] compose iterate-directory drop ] dip ; inline +: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths/f ) + '[ + _ _ _ [ ] 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 diff --git a/basis/windows/shell32/shell32.factor b/basis/windows/shell32/shell32.factor index b8e6d2c2b0..acb0cd279b 100644 --- a/basis/windows/shell32/shell32.factor +++ b/basis/windows/shell32/shell32.factor @@ -94,7 +94,7 @@ ALIAS: ShellExecute ShellExecuteW : shell32-directory ( n -- str ) f swap f SHGFP_TYPE_DEFAULT MAX_UNICODE_PATH "ushort" - [ SHGetFolderPath shell32-error ] keep utf16n alien>string ; + [ SHGetFolderPath drop ] keep utf16n alien>string ; : desktop ( -- str ) CSIDL_DESKTOPDIRECTORY shell32-directory ;