\ 4tH library - BASENAME, DIRNAME - Copyright 2011 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

[UNDEFINED] dirname [IF]
char / value Directory_Separator       \ POSIX standard
                                       ( a1 n1 c -- a2 n2)
: <char/ >r begin dup while 1- 2dup chars + c@ r@ = until r> drop ;
: dirname Directory_Separator <char/ ; ( a1 n1 -- a2 n2)
: -ext [char] . <char/ ;               ( a1 n1 -- a2 n2)

: basename                             ( a1 n2 -- a2 n2)
  2dup tuck dirname dup if 1+ then tuck chars + -rot - dup if 2swap then 2drop
;
[THEN]
