3962c08662
FossilOrigin-Name: 9a36cf9d0e7ddd0131df3867aa4285f0c26ccde64ef7c193729932647d8829a3
35 lines
929 B
Forth
35 lines
929 B
Forth
~~~
|
|
:HOME 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
|
|
~~~
|