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.
							parent
							
								
									d40faa3bdc
								
							
						
					
					
						commit
						d23ab51ce8
					
				| 
						 | 
					@ -12,13 +12,7 @@ HELP: cd
 | 
				
			||||||
{ $description "Changes the current working directory of the Factor process." }
 | 
					{ $description "Changes the current working directory of the Factor process." }
 | 
				
			||||||
{ $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ;
 | 
					{ $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HELP: with-cd
 | 
					{ cd cwd current-directory set-current-directory with-directory } related-words
 | 
				
			||||||
{ $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
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
HELP: current-directory
 | 
					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."
 | 
					{ $description "A variable holding the current directory as an absolute path. Words that use the filesystem do so in relation to this variable."
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
USING: alien alien.c-types alien.data arrays classes.struct
 | 
					USING: alien alien.c-types alien.data arrays classes.struct
 | 
				
			||||||
compiler.units continuations destructors generic.single io
 | 
					compiler.units continuations destructors generic.single io
 | 
				
			||||||
io.directories io.encodings.8-bit.latin1 io.encodings.ascii
 | 
					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
 | 
					io.files.private io.files.temp io.files.unique kernel make math
 | 
				
			||||||
sequences specialized-arrays system threads tools.test vocabs ;
 | 
					sequences specialized-arrays system threads tools.test vocabs ;
 | 
				
			||||||
FROM: specialized-arrays.private => specialized-array-vocab ;
 | 
					FROM: specialized-arrays.private => specialized-array-vocab ;
 | 
				
			||||||
| 
						 | 
					@ -271,7 +271,13 @@ CONSTANT: pt-array-1
 | 
				
			||||||
    [ dispose ] [ dispose ] bi
 | 
					    [ dispose ] [ dispose ] bi
 | 
				
			||||||
] unit-test
 | 
					] 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 } [
 | 
					{ t } [
 | 
				
			||||||
    cwd
 | 
					    cwd
 | 
				
			||||||
    "resource:core/" [ "hi" print ] with-cd
 | 
					    "resource:core/" [ "hi" print ] with-cd
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,11 +70,6 @@ HOOK: cwd io-backend ( -- path )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
M: object cwd ( -- path ) "." ;
 | 
					M: object cwd ( -- path ) "." ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: with-cd ( path quot -- )
 | 
					 | 
				
			||||||
    [ [ absolute-path cd ] curry ] dip compose
 | 
					 | 
				
			||||||
    cwd [ cd ] curry
 | 
					 | 
				
			||||||
    [ ] cleanup ; inline
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE>
 | 
					PRIVATE>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: init-resource-path ( -- )
 | 
					: init-resource-path ( -- )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue