Revert "io.pathnames: Added ~/ (tilde) prefix recognition as a special pathname."

This reverts commit 4e10f09787.
db4
Joe Groff 2012-01-31 11:46:02 -08:00
parent af8dc62104
commit 0ddb6fa96e
3 changed files with 9 additions and 22 deletions

View File

@ -106,8 +106,8 @@ HELP: absolute-path
{ "path" "a pathname string" }
{ "path'" "a pathname string" }
}
{ $description "Prepends the " { $link current-directory } " to the pathname and resolves a " { $snippet "resource:" } ", " { $snippet "~/" } " or " { $snippet "vocab:" } " prefix, if present (see " { $link "io.pathnames.special" } ")." }
{ $notes "This word is exactly the same as " { $link normalize-path } ", except on Windows NT platforms, where it does not prepend the Unicode path prefix. Most code should call " { $link normalize-path } " instead." } ;
{ $description "Prepends the " { $link current-directory } " to the pathname and resolves a " { $snippet "resource:" } " or " { $snippet "vocab:" } " prefix, if present (see " { $link "io.pathnames.special" } ")." }
{ $notes "This word is exaclty the same as " { $link normalize-path } ", except on Windows NT platforms, where it does not prepend the Unicode path prefix. Most code should call " { $link normalize-path } " instead." } ;
HELP: resolve-symlinks
{ $values { "path" "a pathname string" } { "path'" "a new pathname string" } }
@ -131,9 +131,7 @@ HELP: home
ARTICLE: "io.pathnames.special" "Special pathnames"
"If a pathname begins with " { $snippet "resource:" } ", it is resolved relative to the directory containing the current image (see " { $link image } ")."
$nl
"If a pathname begins with " { $snippet "vocab:" } ", then it will be searched for in all current vocabulary roots (see " { $link "add-vocab-roots" } ")."
$nl
"If a pathname begins with " { $snippet "~/" } ", it will be searched for in the home directory. Subsequent tildes in the pathname will be construed as literal tilde path or filenames and will not be treated specially. It should be noted that the " { $snippet "~" } " symbol without a forward slash will be also be treated as a literal path or filename." ;
"If a pathname begins with " { $snippet "vocab:" } ", then it will be searched for in all current vocabulary roots (see " { $link "add-vocab-roots" } ")." ;
ARTICLE: "io.pathnames.presentations" "Pathname presentations"
"Pathname presentations are objects that wrap a pathname string. Clicking a pathname presentation in the UI brings up the file in one of the supported editors. See " { $link "editor" } " for more details."

View File

@ -1,6 +1,6 @@
USING: io.pathnames io.files.temp io.directories
continuations math io.files.private kernel
namespaces sequences tools.test io.pathnames.private ;
namespaces tools.test io.pathnames.private ;
IN: io.pathnames.tests
[ "passwd" ] [ "/etc/passwd" file-name ] unit-test
@ -70,9 +70,3 @@ IN: io.pathnames.tests
! Regression test for bug in file-extension
[ f ] [ "/funny.directory/file-with-no-extension" file-extension ] unit-test
[ "" ] [ "/funny.directory/file-with-no-extension." file-extension ] unit-test
! Testing ~/ special pathname
[ t ] [ "~/" absolute-path home = ] unit-test
[ f ] [ "~" absolute-path home = ] unit-test
[ t ] [ "~/~" absolute-path "/~" home prepend = ] unit-test
[ t ] [ "~/~/" absolute-path "/~/" home prepend = ] unit-test

View File

@ -1,6 +1,6 @@
! Copyright (C) 2004, 2009 Slava Pestov, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators environment io.backend kernel math math.order
USING: accessors combinators io.backend kernel math math.order
namespaces sequences splitting strings system ;
IN: io.pathnames
@ -135,10 +135,6 @@ M: object resolve-symlinks normalize-path ;
: resource-path ( path -- newpath )
"resource-path" get prepend-path ;
HOOK: home io-backend ( -- dir )
M: object home "" resource-path ;
GENERIC: vocab-path ( path -- newpath )
GENERIC: absolute-path ( path -- path' )
@ -151,13 +147,9 @@ M: string absolute-path
"vocab:" ?head [
trim-head-separators vocab-path
absolute-path
] [
"~/" ?head [
trim-head-separators home prepend-path
absolute-path
] [
current-directory get prepend-path
] if ] if
] if
] if ;
M: object normalize-path ( path -- path' )
@ -171,3 +163,6 @@ M: pathname absolute-path string>> absolute-path ;
M: pathname <=> [ string>> ] compare ;
HOOK: home io-backend ( -- dir )
M: object home "" resource-path ;