| r@ cell+ @ over + r@ @ u> ABORT" path buffer too small!" |
r@ cell+ @ over + r@ @ u> ABORT" path buffer too small!" |
| \ copy into |
\ copy into |
| tuck r@ cell+ dup @ cell+ + swap cmove |
tuck r@ cell+ dup @ cell+ + swap cmove |
| \ make delemiter |
\ make delimiter |
| 0 r@ cell+ dup @ cell+ + 2 pick + c! 1 + r> cell+ +! |
0 r@ cell+ dup @ cell+ + 2 pick + c! 1 + r> cell+ +! |
| ; |
; |
| |
|
| dup 0 swap cell+ ! also-path ; |
dup 0 swap cell+ ! also-path ; |
| |
|
| : path+ ( path-addr "dir" -- ) \ gforth |
: path+ ( path-addr "dir" -- ) \ gforth |
| \G add the directory to the search path path-addr. |
\G Add the directory @var{dir} to the search path @var{path-addr}. |
| name rot also-path ; |
name rot also-path ; |
| |
|
| : fpath+ ( "dir" ) \ gforth |
: fpath+ ( "dir" ) \ gforth |
| \G Add the a directory to the Forth search path. |
\G Add directory @var{dir} to the Forth search path. |
| fpath path+ ; |
fpath path+ ; |
| |
|
| : path= ( path-addr "dir1|dir2|dir3" ) \ gforth |
: path= ( path-addr "dir1|dir2|dir3" ) \ gforth |
| \G Make a complete new search path, separator is |. |
\G Make a complete new search path; the path separator is |. |
| name 2dup bounds ?DO i c@ '| = IF 0 i c! THEN LOOP |
name 2dup bounds ?DO i c@ '| = IF 0 i c! THEN LOOP |
| rot only-path ; |
rot only-path ; |
| |
|
| : fpath= ( "dir1|dir2|dir3" ) \ gforth |
: fpath= ( "dir1|dir2|dir3" ) \ gforth |
| \G Make a complete new Forth search path, serparator is |. |
\G Make a complete new Forth search path; the path separator is |. |
| fpath path= ; |
fpath path= ; |
| |
|
| : path>counted cell+ dup cell+ swap @ ; |
: path>counted cell+ dup cell+ swap @ ; |
| BEGIN tuck dup WHILE repeat ; |
BEGIN tuck dup WHILE repeat ; |
| |
|
| : .path ( path-addr -- ) \ gforth |
: .path ( path-addr -- ) \ gforth |
| \G Display the contents of the search path path-addr. |
\G Display the contents of the search path @var{path-addr}. |
| path>counted |
path>counted |
| BEGIN next-path dup WHILE type space REPEAT 2drop 2drop ; |
BEGIN next-path dup WHILE type space REPEAT 2drop 2drop ; |
| |
|
| : .fpath ( -- ) \ gforth |
: .fpath ( -- ) \ gforth |
| \G Display the contents of the Forth search patch. |
\G Display the contents of the Forth search path. |
| fpath .path ; |
fpath .path ; |
| |
|
| : absolut-path? ( addr u -- flag ) \ gforth |
: absolut-path? ( addr u -- flag ) \ gforth |
| open-ofile ; |
open-ofile ; |
| |
|
| \ !! returns 2 stack items if file is not found, not just the ior |
\ !! returns 2 stack items if file is not found, not just the ior |
| : open-path-file ( adr len path-addr -- fd adr1 len2 0 | ior ) \ gforth |
: open-path-file ( addr1 u1 path-addr -- wfileid addr2 u2 0 | ior ) \ gforth |
| \G Look in path path-addr for the file specified by adr len. |
\G Look in path @var{path-addr} for the file specified by @var{addr1 u1}. |
| \G If found the resulting path and an open file descriptor |
\G If found, the resulting path and an open file descriptor |
| \G are returned. If the file is not found ior is non-zero. |
\G are returned. If the file is not found, @var{ior} is non-zero. |
| >r |
>r |
| 2dup absolut-path? |
2dup absolut-path? |
| IF rdrop |
IF rdrop |
| THEN ; |
THEN ; |
| |
|
| \ !! returns 2 stack items if file is not found, not just the ior |
\ !! returns 2 stack items if file is not found, not just the ior |
| : open-fpath-file ( adr len -- fd adr1 len2 0 | ior ) \ gforth |
: open-fpath-file ( addr1 u1 -- wfileid addr2 u2 0 | ior ) \ gforth |
| \G Look in the Forth search path for the file specified by adr len. |
\G Look in the Forth search path for the file specified by @var{addr1 u1}. |
| \G If found the resulting path and an open file descriptor |
\G If found, the resulting path and an open file descriptor |
| \G are returned. If the file is not found ior is non-zero. |
\G are returned. If the file is not found, @var{ior} is non-zero. |
| fpath open-path-file ; |
fpath open-path-file ; |