diff --git a/core/debugger/debugger-docs.factor b/core/debugger/debugger-docs.factor index f8b53d4abc..ca6aa59cc4 100755 --- a/core/debugger/debugger-docs.factor +++ b/core/debugger/debugger-docs.factor @@ -1,6 +1,7 @@ USING: alien arrays generic generic.math help.markup help.syntax kernel math memory strings sbufs vectors io io.files classes -help generic.standard continuations system debugger.private ; +help generic.standard continuations system debugger.private +io.files.private ; IN: debugger ARTICLE: "errors-assert" "Assertions" diff --git a/core/io/files/files-docs.factor b/core/io/files/files-docs.factor index 342967acfc..d1a59f3604 100755 --- a/core/io/files/files-docs.factor +++ b/core/io/files/files-docs.factor @@ -197,19 +197,20 @@ HELP: file-contents HELP: cwd { $values { "path" "a pathname string" } } { $description "Outputs the current working directory of the Factor process." } -{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." } ; +{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." } +{ $warning "Modifying the current directory through system calls is unsafe. Use the " { $link with-directory } " word instead." } ; HELP: cd { $values { "path" "a pathname string" } } { $description "Changes the current working directory of the Factor process." } -{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." } ; +{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." } +{ $warning "Modifying the current directory through system calls is unsafe. Use the " { $link with-directory } " word instead." } ; -{ cd cwd with-directory } related-words +{ cd cwd current-directory with-directory } related-words HELP: with-directory { $values { "path" "a pathname string" } { "quot" quotation } } -{ $description "Changes the current working directory for the duration of a quotation's execution." } -{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." } ; +{ $description "Changes the " { $link current-directory } " variable for the duration of a quotation's execution. Words that use the file-system should call " { $link normalize-path } " in order to obtain a path relative to the current directory." } ; HELP: append-path { $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } } diff --git a/core/io/files/files.factor b/core/io/files/files.factor index 45bf0602f2..08ec78492a 100755 --- a/core/io/files/files.factor +++ b/core/io/files/files.factor @@ -176,15 +176,18 @@ SYMBOL: +unknown+ : directory? ( path -- ? ) file-info file-info-type +directory+ = ; -! Current working directory + + +SYMBOL: current-directory + [ cwd current-directory set-global ] "io.files" add-init-hook : resource-path ( path -- newpath ) diff --git a/extra/editors/jedit/jedit.factor b/extra/editors/jedit/jedit.factor index 92320addef..e4f19781ef 100755 --- a/extra/editors/jedit/jedit.factor +++ b/extra/editors/jedit/jedit.factor @@ -4,7 +4,7 @@ USING: arrays definitions io kernel math namespaces parser prettyprint sequences strings words editors io.files io.sockets io.streams.byte-array io.binary math.parser io.encodings.ascii io.encodings.binary -io.encodings.utf8 ; +io.encodings.utf8 io.files.private ; IN: editors.jedit : jedit-server-info ( -- port auth ) diff --git a/extra/io/unix/files/files.factor b/extra/io/unix/files/files.factor index f6bb3edcde..3085827483 100755 --- a/extra/io/unix/files/files.factor +++ b/extra/io/unix/files/files.factor @@ -3,10 +3,13 @@ USING: io.backend io.nonblocking io.unix.backend io.files io unix unix.stat unix.time kernel math continuations math.bitfields byte-arrays alien combinators calendar -io.encodings.binary accessors sequences strings system ; +io.encodings.binary accessors sequences strings system +io.files.private ; IN: io.unix.files + ] [ ] bi getcwd [ (io-error) ] unless* ; @@ -14,6 +17,8 @@ M: unix cwd ( -- path ) M: unix cd ( path -- ) chdir io-error ; +PRIVATE> + : read-flags O_RDONLY ; inline : open-read ( path -- fd ) diff --git a/extra/io/unix/sockets/sockets.factor b/extra/io/unix/sockets/sockets.factor index 477757e0ed..a54205a878 100755 --- a/extra/io/unix/sockets/sockets.factor +++ b/extra/io/unix/sockets/sockets.factor @@ -7,7 +7,7 @@ USING: alien alien.c-types generic io kernel math namespaces io.nonblocking parser threads unix sequences byte-arrays io.sockets io.binary io.unix.backend io.streams.duplex io.sockets.impl math.parser continuations libc -combinators io.backend io.files system ; +combinators io.backend io.files io.files.private system ; IN: io.unix.sockets : pending-init-error ( port -- ) diff --git a/extra/io/windows/nt/files/files.factor b/extra/io/windows/nt/files/files.factor index 7bac540ddc..590bc59023 100755 --- a/extra/io/windows/nt/files/files.factor +++ b/extra/io/windows/nt/files/files.factor @@ -5,6 +5,8 @@ alien.c-types alien.arrays sequences combinators combinators.lib sequences.lib ascii splitting alien strings assocs namespaces ; IN: io.windows.nt.files + [ GetCurrentDirectory win32-error=0/f ] keep @@ -13,6 +15,8 @@ M: winnt cwd M: winnt cd SetCurrentDirectory win32-error=0/f ; +PRIVATE> + : unicode-prefix ( -- seq ) "\\\\?\\" ; inline