add unix canonicalize-path

db4
Doug Coleman 2009-02-18 13:34:45 -06:00
parent 2af9d5a6df
commit 6324fb6c13
2 changed files with 8 additions and 2 deletions

View 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 ;

View 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 ;