]> gitweb.factorcode.org Git - factor.git/commitdiff
add unix canonicalize-path
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 18 Feb 2009 19:34:45 +0000 (13:34 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 18 Feb 2009 19:34:45 +0000 (13:34 -0600)
basis/io/files/info/unix/linux/linux.factor
basis/io/files/links/unix/unix.factor

index 5dddca4f9d005928402609ee44f0a29f2b3afbf4..72401004ae96dd0cf77222273e3e0f85eeddbb51 100644 (file)
@@ -72,13 +72,14 @@ M: linux file-systems
     ] map ;
 
 : (find-mount-point) ( path mtab-paths -- mtab-entry )
-    [ follow-links ] dip 2dup at* [
+    2dup at* [
         2nip
     ] [
         drop [ parent-directory ] dip (find-mount-point)
     ] if ;
 
 : find-mount-point ( path -- mtab-entry )
+    canonicalize-path
     parse-mtab [ [ mount-point>> ] keep ] H{ } map>assoc (find-mount-point) ;
 
 ERROR: file-system-not-found ;
index 2f38c39e02a3a91a835e5d9b7362ef6ceeb7e807..7d2a6ee4f3c31b474388fc6f78589a39e2850ece 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io.backend io.files.links system unix ;
+USING: io.backend io.files.links system unix io.pathnames kernel
+io.files sequences ;
 IN: io.files.links.unix
 
 M: unix make-link ( path1 path2 -- )
@@ -8,3 +9,7 @@ M: unix make-link ( path1 path2 -- )
 
 M: unix read-link ( path -- path' )
     normalize-path read-symbolic-link ;
+
+M: unix canonicalize-path ( path -- path' )
+    path-components "/"
+    [ append-path dup exists? [ follow-links ] when ] reduce ;