normalize-pathname all ova tha place

db4
erg 2008-03-26 22:39:16 -05:00
parent 4684c9cacc
commit 24466cfc57
7 changed files with 28 additions and 15 deletions

View File

@ -132,15 +132,12 @@ io.encodings.utf8 ;
[ t ] [ cwd "misc" resource-path [ ] with-directory cwd = ] unit-test
[ t ] [
temp-directory [ "hi" "test41" utf8 set-file-contents ] with-directory
temp-directory [ "hi41" "test41" utf8 set-file-contents ] with-directory
temp-directory "test41" append-path utf8 file-contents "hi41" =
] unit-test
[ t ] [
temp-directory [
"test43" utf8 <file-writer> [ "hi43" write ] with-stream
] with-directory
temp-directory "test43" append-path utf8 file-contents "hi43" =
temp-directory [ "test41" file-info size>> ] with-directory 4 =
] unit-test
[ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test

View File

@ -13,13 +13,13 @@ HOOK: (file-writer) io-backend ( path -- stream )
HOOK: (file-appender) io-backend ( path -- stream )
: <file-reader> ( path encoding -- stream )
swap (file-reader) swap <decoder> ;
swap normalize-pathname (file-reader) swap <decoder> ;
: <file-writer> ( path encoding -- stream )
swap (file-writer) swap <encoder> ;
swap normalize-pathname (file-writer) swap <encoder> ;
: <file-appender> ( path encoding -- stream )
swap (file-appender) swap <encoder> ;
swap normalize-pathname (file-appender) swap <encoder> ;
: file-lines ( path encoding -- seq )
<file-reader> lines ;

View File

@ -94,7 +94,7 @@ M: unix-io copy-file ( from to -- )
\ file-info construct-boa ;
M: unix-io file-info ( path -- info )
stat* stat>file-info ;
normalize-pathname stat* stat>file-info ;
M: unix-io link-info ( path -- info )
lstat* stat>file-info ;
normalize-pathname lstat* stat>file-info ;

View File

@ -1,7 +1,7 @@
IN: io.unix.launcher.tests
USING: io.files tools.test io.launcher arrays io namespaces
continuations math io.encodings.binary io.encodings.ascii
accessors kernel sequences ;
accessors kernel sequences io.encodings.utf8 ;
[ ] [
[ "launcher-test-1" temp-file delete-file ] ignore-errors
@ -95,3 +95,15 @@ accessors kernel sequences ;
+replace-environment+ >>environment-mode
ascii <process-stream> lines
] unit-test
[ "hi\n" ] [
temp-directory [
[ "aloha" delete-file ] ignore-errors
<process>
{ "echo" "hi" } >>command
"aloha" >>stdout
try-process
] with-directory
temp-directory "aloha" append-path
utf8 file-contents
] unit-test

View File

@ -37,7 +37,8 @@ USE: unix
2nip reset-fd ;
: redirect-file ( obj mode fd -- )
>r file-mode open dup io-error r> redirect-fd ;
>r >r normalize-pathname r> file-mode
open dup io-error r> redirect-fd ;
: redirect-closed ( obj mode fd -- )
>r >r drop "/dev/null" r> r> redirect-file ;
@ -67,9 +68,9 @@ USE: unix
: spawn-process ( process -- * )
[
current-directory get cd
setup-priority
setup-redirection
current-directory get cd
dup pass-environment? [
dup get-environment set-os-envs
] when

View File

@ -89,4 +89,7 @@ SYMBOLS: +read-only+ +hidden+ +system+
] if ;
M: windows-nt-io file-info ( path -- info )
get-file-information-stat ;
normalize-pathname get-file-information-stat ;
M: windows-nt-io link-info ( path -- info )
file-info ;

View File

@ -51,7 +51,7 @@ M: win32-file close-handle ( handle -- )
! Clean up resources (open handle) if add-completion fails
: open-file ( path access-mode create-mode flags -- handle )
[
>r >r >r normalize-pathname r>
>r >r
share-mode security-attributes-inherit r> r> CreateFile-flags f CreateFile
dup invalid-handle? dup close-later
dup add-completion