
: $DIR ( addr len -- )
  OPEN-DIR THROW
  DUP DIR2COUNT 0
  DO    DUP I DIRI2TYPE 5 =
	IF ." <ПАПКА>" THEN 9 EMIT
	DUP I DIRI2NAME ZTYPE CR
 LOOP
  CLOSE-DIR DROP
;

: DIR PARSE-NAME $DIR ;

: $CHDIR ( adr len -- )
 DUP 0= IF 2DROP BREAK
\ G_CLI_PATH ZCOUNT + 1- C@ '\' <> IF '\' qqqqq THEN
 OVER W@  $2E2E ( ..) =
  IF 2DROP
	G_CLI_PATH ZCOUNT NIP 4 < IF BREAK
	BEGIN	G_CLI_PATH ZCOUNT + 1- 0!
		G_CLI_PATH ZCOUNT + 1- C@ '\' =
	UNTIL
  BREAK
 OVER 1+ C@ ':' = \ root
 IF    G_CLI_PATH	OVER + 0!  G_CLI_PATH SWAP CMOVE
 ELSE  G_CLI_PATH ZCOUNT + OVER + 0!   G_CLI_PATH ZCOUNT + SWAP CMOVE
 THEN
 G_CLI_PATH ZCOUNT + 1- C@ '\' <> IF '\' G_CLI_PATH ZCOUNT + W! THEN
 ;


: CD PARSE-NAME $CHDIR ;

: PWD G_CLI_PATH ZTYPE ;

