Subversion Repositories Kolibri OS

Rev

Rev 4867 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. VARIABLE wd 256 ALLOT
  2.  
  3. : setwd ( uaddr)
  4.         COUNT 1+ SWAP 1- SWAP wd SWAP CMOVE ;
  5.  
  6. : _wd
  7.         $" /sys/" setwd ; _wd
  8.  
  9. : "/ [CHAR] / ;
  10.  
  11. : strcat ( uaddr1 uaddr2 -- uaddr1+uaddr2)
  12.         >R DUP COUNT ( ua1 a1 c1)
  13.         >R R@ ( ua1 a1 c1)
  14.         + OVER R> R@ SWAP >R ( ua1 ea1 ua1 ua1)
  15.         C@ R> + ( ua1 ea1 ua1 u+u2 )
  16.         SWAP C! ( ua1 ea1 )
  17.         R> COUNT ( ua1 ea1 a2 c2)
  18.         >R
  19.         SWAP R> CMOVE ;
  20.  
  21. : add/ ( uaddr -- uaddr/)
  22.         DUP DUP COUNT SWAP DROP + C@ "/ = IF ELSE $" /" strcat THEN     ;
  23.  
  24. : cut/ ( uaddr -- uaddr w/o slash)
  25.         COUNT OVER SWAP + 1- ( ua1 lasta1)
  26.         DUP C@ "/ = IF 1- THEN .S
  27.         BEGIN 2DUP < WHILE 4 . DUP C@ "/ = IF OVER - OVER 1- C! 1- LEAVE ELSE 1- THEN
  28.         REPEAT ;
  29.  
  30. : t $" cat" $" dog" strcat COUNT TYPE ;
  31.  
  32. : makepath ( path normalizer: uaddr1 uaddr2 -- uaddr )
  33.         DUP 1+ C@ [CHAR] / = IF SWAP DROP ELSE DUP strcat THEN
  34.         add/ ;
  35.  
  36.  
  37. : pwd ( print working directory:  -- )
  38.         CR wd COUNT TYPE ;
  39.  
  40. : cd ( change directory)
  41.         wd BL WORD makepath setwd ;
  42.