a514c52369
FossilOrigin-Name: b6f90144f0af13ac973f6f4d5d6bbea38f8686cd218d14f6f7df03dc8dce89b8
35 lines
935 B
Forth
35 lines
935 B
Forth
~~~
|
|
:HOME (:-s) here #4096 + ;
|
|
|
|
'%s/.config/retroforth/library/%s.retro 'library:.CONFIG s:const (:-s)
|
|
'./library/%s.retro 'library:CWD s:const (:-s)
|
|
|
|
:library:cwd (:s-s) library:CWD s:format ;
|
|
|
|
:library:.config (:-s)
|
|
'HOME HOME unix:getenv
|
|
HOME library:.CONFIG s:format ;
|
|
|
|
:library:filename (:s-s)
|
|
dup library:cwd
|
|
dup file:exists? &nip if; drop
|
|
library:.config dup file:exists? [ ] if; drop s:empty ;
|
|
|
|
:library:contains? (:s-f)
|
|
&library:cwd &library:.config bi &file:exists? bi@ or ;
|
|
|
|
:library:load (:s-)
|
|
dup library:contains? [ library:filename include ]
|
|
[ 'ERROR:_Library_`%s`_was_not_found s:format s:put nl ] choose ;
|
|
|
|
'interface/library.retro s:dedup
|
|
dup 'library:load d:set-source
|
|
dup 'library:contains? d:set-source
|
|
dup 'library:filename d:set-source
|
|
dup 'library:.config d:set-source
|
|
dup 'library:cwd d:set-source
|
|
dup 'library:CWD d:set-source
|
|
dup 'library:.CONFIG d:set-source
|
|
dup 'HOME d:set-source
|
|
drop
|
|
~~~
|