io.files: Move with-cd to the tests file so that nobody uses it. My bad. Basically nobody should ever use cd or cwd for anything. Fixes #1214.

db4
Doug Coleman 2014-11-23 01:37:25 -08:00
parent d40faa3bdc
commit d23ab51ce8
3 changed files with 9 additions and 14 deletions

View File

@ -12,13 +12,7 @@ HELP: cd
{ $description "Changes the current working directory of the Factor process." }
{ $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ;
HELP: with-cd
{ $values
{ "path" "a pathname string" } { "quot" quotation }
}
{ $description "Changes Factor's current working directory (as far as the operating system is concerned). Then, calls the quotation and restores the original directory even if an error is thrown." } ;
{ cd cwd with-cd current-directory set-current-directory with-directory } related-words
{ cd cwd current-directory set-current-directory with-directory } related-words
HELP: current-directory
{ $description "A variable holding the current directory as an absolute path. Words that use the filesystem do so in relation to this variable."

View File

@ -1,7 +1,7 @@
USING: alien alien.c-types alien.data arrays classes.struct
compiler.units continuations destructors generic.single io
io.directories io.encodings.8-bit.latin1 io.encodings.ascii
io.encodings.binary io.encodings.string io.files
io.encodings.binary io.encodings.string io.files io.pathnames
io.files.private io.files.temp io.files.unique kernel make math
sequences specialized-arrays system threads tools.test vocabs ;
FROM: specialized-arrays.private => specialized-array-vocab ;
@ -271,7 +271,13 @@ CONSTANT: pt-array-1
[ dispose ] [ dispose ] bi
] unit-test
! Test with-cd
! Test cwd, cd. You do not want to use with-cd, you want with-directory.
: with-cd ( path quot -- )
[ [ absolute-path cd ] curry ] dip compose
cwd [ cd ] curry
[ ] cleanup ; inline
{ t } [
cwd
"resource:core/" [ "hi" print ] with-cd

View File

@ -70,11 +70,6 @@ HOOK: cwd io-backend ( -- path )
M: object cwd ( -- path ) "." ;
: with-cd ( path quot -- )
[ [ absolute-path cd ] curry ] dip compose
cwd [ cd ] curry
[ ] cleanup ; inline
PRIVATE>
: init-resource-path ( -- )