]> gitweb.factorcode.org Git - factor.git/commitdiff
Remove library/binary-roots, add walk-dir and find-file to io.paths
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 9 Dec 2007 17:42:35 +0000 (11:42 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 9 Dec 2007 17:42:35 +0000 (11:42 -0600)
extra/io/paths/paths.factor [new file with mode: 0644]
extra/io/unix/files/files.factor
extra/io/windows/windows.factor

diff --git a/extra/io/paths/paths.factor b/extra/io/paths/paths.factor
new file mode 100644 (file)
index 0000000..3afb110
--- /dev/null
@@ -0,0 +1,24 @@
+USING: assocs io.files kernel namespaces sequences ;
+IN: io.paths
+
+: find-file ( seq str -- path/f )
+    [
+        [ path+ exists? ] curry find nip
+    ] keep over [ path+ ] [ drop ] if ;
+
+<PRIVATE
+: append-path ( path files -- paths )
+    [ path+ ] curry* map ;
+
+: get-paths ( dir -- paths )
+    dup directory keys append-path ;
+
+: (walk-dir) ( path -- )
+    dup directory? [
+        get-paths dup % [ (walk-dir) ] each
+    ] [
+        drop
+    ] if ;
+PRIVATE>
+
+: walk-dir ( path -- seq ) [ (walk-dir) ] { } make ;
index 8f1d05876db4ff96e17275133bac71578d7cc7cd..f9d642d66134a02fee360ca4235c8e9eb6d552b5 100755 (executable)
@@ -38,21 +38,3 @@ M: unix-io make-directory ( path -- )
 
 M: unix-io delete-directory ( path -- )
     rmdir io-error ;
-
-M: unix-io binary-roots ( -- seq )
-    {
-        "/bin" "/sbin"
-        "/usr/bin" "/usr/sbin"
-        "/usr/local/bin" "/usr/local/sbin"
-        "/opt/local/bin" "/opt/local/sbin"
-        "~/bin"
-    } ;
-
-M: unix-io library-roots ( -- seq )
-    {
-        "/lib"
-        "/usr/lib"
-        "/usr/local/lib"
-        "/opt/local/lib"
-        "/lib64"
-    } ;
index 2defa48298e9ea6e518be2bd36f3a87735ce7acf..8dcb138999e9d7da13be3317ba6b74ae265b42c5 100755 (executable)
@@ -11,16 +11,6 @@ TUPLE: windows-nt-io ;
 TUPLE: windows-ce-io ;
 UNION: windows-io windows-nt-io windows-ce-io ;
 
-M: windows-io library-roots ( -- seq )
-    [
-        windows ,
-    ] { } make ;
-
-M: windows-io binary-roots ( -- seq )
-    [
-        windows ,
-    ] { } make ;
-
 M: windows-io destruct-handle CloseHandle drop ;
 
 M: windows-io destruct-socket closesocket drop ;