From d23ab51ce8006a0b6df29646e5acc9e887ad1d40 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 23 Nov 2014 01:37:25 -0800 Subject: [PATCH] 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. --- basis/io/directories/directories-docs.factor | 8 +------- core/io/files/files-tests.factor | 10 ++++++++-- core/io/files/files.factor | 5 ----- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/basis/io/directories/directories-docs.factor b/basis/io/directories/directories-docs.factor index 0380d69522..11ab475f9a 100644 --- a/basis/io/directories/directories-docs.factor +++ b/basis/io/directories/directories-docs.factor @@ -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." diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index 011964f8e1..b48146e39a 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -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 diff --git a/core/io/files/files.factor b/core/io/files/files.factor index 58f2b8af3b..aa77ebd15d 100644 --- a/core/io/files/files.factor +++ b/core/io/files/files.factor @@ -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 ( -- )