[SLOF] [PATCH] Add a global "dir" method
Segher Boessenkool
segher at kernel.crashing.org
Thu Jun 9 17:18:45 AEST 2016
On Thu, Jun 09, 2016 at 01:46:46PM +1000, Benjamin Herrenschmidt wrote:
> +: do-dir ( devstr len -- )
> + cr ." Directory of: " 2dup type ." ... "
That is debug code, right? The user knows what he typed, and if not,
he can always look one line up ;-)
> + open-dev dup IF
> + s" dir" 2 pick ['] $call-method CATCH IF
> + ." no dir method on target !" cr
> + 3drop
> + THEN
> + close-dev cr
> + ELSE drop THEN
> +;
dup IF ... ELSE drop THEN
is the same as
?dup IF ... THEN
> +: dir ( "{devstring}" -- )
> + parse-word de-alias do-dir
> +;
A more usual name for do-dir would be (dir) or $dir .
> +: find-path ( dir-cluster name len -- cluster file-len is-dir? true | false )
Things will be simpler if you store to dir? directly here, instead of
passing it around.
As an aside, a word that ends in a question mark usually leaves a
boolean on the stack, not an address.
> + \ Store right side on return stack
> + 2>r
Useless comments are useless ;-)
Segher
More information about the SLOF
mailing list