Post Reply 
(48G/GX) DIRSTAT - Find RAM Hogs
05-16-2014, 05:43 PM
Post: #1
(48G/GX) DIRSTAT - Find RAM Hogs
As the name suggests, this is a clone of programs like WinDirStat/KDirStat. Run it to see the sizes of all variables and subdirectories in the current directory, sorted in descending order of size. You can then navigate to other directories by selecting them and pressing ENTER (then waiting for the program to rebuild the list). There's a lot of G/GX-specific stuff here, so it's not compatible with the S/SX without heavy modification. The installed size is 481 bytes.

This also requires CHOOSF, which is a drop-in full-screen replacement for CHOOSE. You can either get CHOOSF from this old Usenet posting, or just download the 48G/GX version attached to this post. The installed size of CHOOSF is only 109.5 bytes. Definitely worth having around if you use CHOOSE at all.

Code:
%%HP: T(3)A(D)F(.);
\<< 0 \-> T
  \<<
    DO
      0 'T' STO
@ Get the current directory name for the title bar.
      PATH DUP SIZE GET "" +
      "Getting contents..." 1 DISP
@ List all vars and...
      VARS 1
@ ...build a list item for each: { size { "name: size" name } }
@ Also total up the bytes used in the current dir.
@ Pardon the opaque stackrobatics here. (And also the portmanteau.)
      \<< DUP BYTES
        SWAP DROP DUP 'T'
        STO+ OVER DUP VTYPE
        15 == "\\ " ": "
        IFTE + OVER + ROT 2
        \->LIST 2 \->LIST
      \>> DOLIST
@ Add total bytes to the window title.
      SWAP ": " + T \->STR + SWAP
@ Sort vars descending by the first element of each sublist (bytes).
      "Sorting..." 1 DISP
      SORT REVLIST
      "Preparing..." 1 DISP
@ Pull out the { "name: size" name } sublists to pass to CHOOSF.
      1
      \<< 2 GET
      \>> DOLIST
@ Add a ".." item if we're not in HOME already.
      IF PATH SIZE 1 >
      THEN
        { { ".." \<< UPDIR \>> } } SWAP +
      END
      "" 1 DISP
@ Put highlight on first item.
      1
@ Show the CHOOSF window.
      IF CHOOSF
      THEN
        CASE
@ User selected an item with a subroutine attached (e.g. "..").
@ Run it then reload.
          DUP TYPE 8 == THEN EVAL 0 END
@ User selected a directory. Navigate to it and reload.
          DUP VTYPE 15 == THEN EVAL 0 END
@ User selected something else. Recall it to the stack and exit.
          RCL 1
        END
@ User canceled the CHOOSF window. Just exit.
      ELSE
        1
      END
    UNTIL
    END
  \>>
\>>


.zip  CHOOSF.zip (Size: 216 bytes / Downloads: 5)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(48G/GX) DIRSTAT - Find RAM Hogs - Dave Britten - 05-16-2014 05:43 PM



User(s) browsing this thread: 1 Guest(s)