THEN
;
+ \ A limit used to perform a sanity check on the size argument for
+ \ RESIZE-FILE.
+ 2variable RESIZE-FILE-LIMIT
+ 10000000 0 resize-file-limit 2! \ 10MB is somewhat arbitrarily chosen
+
+ : RESIZE-FILE ( ud fileid -- ior )
+ -rot 2dup resize-file-limit 2@ d> ( fileid ud big? )
+ IF
+ ." Argument (" 0 d.r ." ) is larger then RESIZE-FILE-LIMIT." cr
+ ." (You can increase RESIZE-FILE-LIMIT with 2!)" cr
+ abort
+ ELSE
+ rot (resize-file)
+ THEN
+ ;
+
: ( ( "comment<rparen>" -- )
source-id
CASE
ENDCASE
; immediate
+\ We basically try to open the file in read-only mode. That seems to
+\ be the best that we can do with ANSI C. If we ever want to do
+\ something more sophisticated, like calling access(2), we must create
+\ a proper primitive. (OTOH, portable programs can't assume much
+\ about FILE-STATUS and non-portable programs could create a custom
+\ function for access(2).)
+: FILE-STATUS ( c-addr u -- 0 ior )
+ r/o bin open-file ( fileid ior1 )
+ ?dup
+ IF nip 0 swap ( 0 ior1 )
+ ELSE close-file 0 swap ( 0 ior2 )
+ THEN
+;
+
privatize
rot = -rot = and
;
+ : D< ( d1 d2 -- flag )
+ d- nip 0<
+ ;
+
+ : D> ( d1 d2 -- flag )
+ 2swap d<
+ ;
+
\ define some useful constants ------------------------------
1 0= constant FALSE
0 0= constant TRUE
variable TRACE-INCLUDE
: INCLUDE.MARK.START ( c-addr u -- , mark start of include for FILE?)
- " ::::" pad $MOVE
- pad $APPEND
- pad ['] noop (:)
+ dup 5 + allocate throw >r
+ " ::::" r@ $move
+ r@ $append
+ r@ ['] noop (:)
+ r> free throw
;
: INCLUDE.MARK.END ( -- , mark end of include )