Filename parsing





: get-path      \ *name len -- *name2 len2
Return the string up to (to the left of) the next directory separator.

: get-next-path \ *name len -- next-addr next-len
Return the string to the right of the first path, including any director separator.

: from-root?    \ *name len -- t/f
Returns true if the first character of the string is a directory separator.

: get-fid       { l_*name l_q-len l_dir-buff | l_f-num l_wild -- file-num|0 }
Look for file name in a directory block buffer. If the file is found return its index, otherwise return 0.

: find-file?    { l_dir-blk l_*name l_len | l_*buff -- fn|0 }
Look for file name in a directory block. If the file is found return its index, otherwise return 0.

: no-of-paths   \ caddr len -- n
Count the number of directory levels in file name.

: set-default-dir       \ --
Set the working directory to the root directory.

: step-next-dir         \ *name len buff -- *name1 len1 dir-blk
Step to the next directory in the pathname (using the given directory block buffer), make that the current directory, and return the remaining path name and directory block number.

: get_fn        { l_*name l_len | l_dir l_fld l_*fld -- fld-num|0 }
Given a path/file name, return the file index number if found or zero if not found. Directory path numbers are negated.

: find-next-fld { | l_fld l_*buff -- fld-no }
Find the next free FLD number, returning -1 if there is no more space, or 0 if buffer memory is exhausted.

: inc-str-len   \ n --
COMPILER: increase size of working directory string.

: add-delimit-str       \ --
Add a directory separator to the working directory string.

: clr-dir-str   \ --
Clear the working directory string.

: append-dir-str        \ caddr len --
Append the string to the working directory string.

: move-back-dir \ --
Move back one level in the working directory string.

: back-dir?     \ *name -- t/f
Return true if the start of the name is '..'.

: remove-dir-hdr        \ *name len -- '*name 'len
Remove a directory header from the name.