version 1.27, 2005/12/31 15:46:14
|
version 1.28, 2006/01/31 14:10:38
|
Line 233 Create tfile 0 c, 255 chars allot
|
Line 233 Create tfile 0 c, 255 chars allot
|
expandtopic reworkdir |
expandtopic reworkdir |
ofile count r/o open-file ; |
ofile count r/o open-file ; |
|
|
: check-path ( adr1 len1 adr2 len2 -- fd 0 | 0 <>0 ) |
: check-path ( adr1 len1 adr2 len2 -- fid 0 | 0 ior ) |
0 ofile ! >r >r ofile place need/ |
0 ofile ! >r >r ofile place need/ |
r> r> ofile +place |
r> r> ofile +place |
open-ofile ; |
open-ofile ; |
|
|
\ !! allow arbitrary FAMs, not just R/O |
\ !! allow arbitrary FAMs, not just R/O |
: open-path-file ( addr1 u1 path-addr -- wfileid addr2 u2 0 | ior ) \ gforth |
: open-path-file ( addr1 u1 path-addr -- wfileid addr2 u2 0 | ior ) \ gforth |
\G Look in path @var{path-addr} for the file specified by @var{addr1 u1}. |
\G Look in path @var{path-addr} for the file specified by @var{addr1 |
\G If found, the resulting path and and (read-only) open file descriptor |
\G u1}. If found, the resulting path and and (read-only) open file |
\G are returned. If the file is not found, @var{ior} is non-zero. |
\G descriptor are returned. If the file is not found, @var{ior} is |
>r |
\G what came back from the last attempt at opening the file (in the |
2dup absolut-path? |
\G current implementation). |
IF rdrop |
>r |
|
2dup absolut-path? IF |
|
rdrop |
ofile place open-ofile |
ofile place open-ofile |
dup 0= IF >r ofile count r> THEN EXIT |
dup 0= IF |
ELSE r> path>string |
>r ofile count r> THEN |
BEGIN next-path dup |
EXIT |
WHILE 5 pick 5 pick check-path |
ELSE |
0= IF >r 2drop 2drop r> ofile count 0 EXIT ELSE drop THEN |
r> -&37 >r path>string BEGIN |
REPEAT |
next-path dup WHILE |
2drop 2drop 2drop -&37 |
r> drop |
|
5 pick 5 pick check-path dup 0= IF |
|
drop >r 2drop 2drop r> ofile count 0 EXIT |
|
ELSE |
|
>r drop |
|
THEN |
|
REPEAT |
|
2drop 2drop 2drop r> |
THEN ; |
THEN ; |
|
|
: open-fpath-file ( addr1 u1 -- wfileid addr2 u2 0 | ior ) \ gforth |
: open-fpath-file ( addr1 u1 -- wfileid addr2 u2 0 | ior ) \ gforth |