cQGSIZE(t) ;Data-M Global Size Utility ;cQGSIZE; [ 07/16/01 1:51 PM ] S t=+$G(t) ; START D GDB^cQAUTOBU(.V) I '$D(V($ZU(5))) Q S B=X($ZU(5),"globals"),B=$P(B,"\",1,$L(B,"\")-2)_"\" D MASTER^cQ5 S EX="\CacheTemp\ERRORS\HULP\ROUTINE\TEMP\TMP\UTILITY\ZZLOG\cIPRINT\cJOB\cLOG\cPRINT\cQSYS\cTABEL\mtemp\mtemp0\mtemp1\rOBJ\" S home=cs,LOG="^|home|ZZLOG(""%GSIZE"",""calc"")" K @LOG F I=0:1:99 S DIR=B_I_"\" I $L($zu(12,DIR,3)) D GET SUM S G="",LOGN="^|home|ZZLOG(""%GSIZE"",""sum"")",LOGS="^|home|ZZLOG(""%GSIZE"",""sorted"")" K @LOGN,@LOGS F S G=$O(@LOG@(G)) Q:G="" S H="",S=0 D S @LOGN@(G)=S I G'=0 S @LOGS@(S,G)="" . F S H=$O(@LOG@(G,H)) Q:H="" S S=$P(^(H),"\")*2048+S I G=0 S @LOGN@(G,H)=$P(@LOG@(G,H),"\")*2048 D COLL S PG=$T(+0),PN=$P($T(T0),";",2) D D1016^cANEM0(PG,PN,.R) Q ; DISP(t) S t=+$G(t) D COLL F I=1:1:R W !,R(I) Q ; COLL ; Collect data D MASTER^cQ5 S t=+$G(t),home=cs,LOG="^|home|ZZLOG(""%GSIZE"",""calc"")" S LOGN="^|home|ZZLOG(""%GSIZE"",""sum"")",LOGS="^|home|ZZLOG(""%GSIZE"",""sorted"")" K R S S=0,G="",R=0 F S G=$O(@LOGN@(0,G)) Q:G="" S S=^(G)+S,R=R+1,R(R)=$E(G,3,$L(G)),$E(R(R),30)=$J(^(G)\1024\1024,20,2)_" MB" S R=R+1,$E(R(R),30)="-----------------------",R=R+1,$E(R(R),30)=$J(S\1024\1024,20,2)_" MB" S R=R+1,R(R)="",S="" F I=1:1:t S S=$O(@LOGS@(S),-1) Q:S="" S H="" D . F S H=$O(@LOGS@(S,H)) Q:H="" S R=R+1,R(R)=$J(I,2)_". ^"_H,$E(R(R),15)=$J(S\1024\1024,20,2)_" MB" F I=1:1:R S R(I)=$TR(R(I),"\","/") Q ; GET s ONSP=$zu(5) zn "^^"_DIR ;save current namespace D PHYSICAL^%GLO(1) K ^%utility($j) S X=$$Fetch^%GD("*",1,0) K ^UTILITY($J) S g="" F S g=$O(^%utility($J,g)) q:g="" S ^UTILITY($J,$e(g,2,$L(g)))="" F J=1:1:$L(EX,"\") S g=$P(EX,"\",J) I $L(g) K ^UTILITY($J,g) g exit:$o(^UTILITY($j,""))="" s G="",P=1,(tbytes,tblks,tcont,DX)=0 d showless exit zn ONSP k %ST q ; showless ;inherit all variables from caller, call brief(), and display S H=$zu(5) f s G=$o(^UTILITY($j,G)) q:G="" d . I EX[("\"_G_"\") Q . i '$p(^UTILITY("GLO",G),"^",3) q . s x=$$brief("^"_G),blks=+x,tblks=tblks+blks . i x'["?" S @LOG@(G,H)=blks . e S @LOG@(G,H)=$p(x,"?",2) S @LOG@(0,H)=tblks_"\"_$TR($ZD(+$H,4),"/",".")_"\"_$ZT($P($H,",",2),1) q ; brief(G) ;brief version (quicker) n (G,%ST) s k=0 ;k:blocks o 63 d:'$d(%ST("GVEC")) ^%ST i $d(@G) s b=$v($v(%ST("GVEC"),-1,"4P")+%ST("gpnt")+%ST("indian"),-3,3) ;1st pointer block i 'b s err="?GLOBAL" g exitbrf f q:'b v b s t=$V(2043,0,1) q:t=6 s b=$v(2,-5) i 'b s err="?BOTPNT" g exitbrf f k big s lastbig=-1,big=0 q:'b v b d s k=k+i-1 . f i=1:1 s x=$v(i*2-1,-6) q:x="" s p=$v(i*2,-6) d:p\8388608#2 . . i lastbig=(i-1) s $p(big(big),",",2)=p#8388608 . . e s big=big+1,big(big)=p#8388608 . . s lastbig=i . s b=$V(2040,0,"3O") ;get next linked block before doing big blocks . s j="" f s j=$o(big(j)) q:j="" s k=k+$$bigblk(big(j)) exitbrf c 63 q k_$g(err) bigblk(b) ; n (b) s beg=+$p(b,","),end=+$p(b,",",2) s:'end end=beg q:'beg 0 s b=beg,k=0 f v b q:$V(2043,0,1)'=12 d q:b=end s b=$V(2040,0,"3O") q:'b . f i=1:1 s x=$v(i*2-1,-6) q:x="" d . . s v=$v(i*2,-6) q:$a(v)'=3 . . s k=k+$a(v,2)+''($a(v,3)!$a(v,4)) q k YN(P,D,t) N R,X S P=$G(P),D=$E($G(D)_"?"),t=$G(t) ;ask Yes/No w/ Prompt,Default S D=$S("Yy"[D:"Yes => ","Nn"[D:"No => ",1:"") ;Yes, No or no default F W !,P_"? "_D Read:t R:t Read:'t R DO I "^YN"[R Q ;timed or non-timed read . S X=R,R=$TR($E(R_D_"?"),"yn","YN") I "^YN"'[R W " enter Yes or No, please" S POP=(R="^") W $E($S(R="N":"No",R="Y":"Yes",1:""),$L(X)+1,3) Q R GetDir(p,d,exists) ;ask for a directory, allow defaults i '$D(exists) s exists=1 ; default is to check if exists n neednew s neednew=1 ;expect to new dirlist i $g(dirlist) i $g(@dirlist) s neednew=0 ; callers dirlist seems ok i neednew n dirlist d . S dirlist="mtemp1(""dir"")" ;as good a place as any... . I $G(@dirlist)<$H K @dirlist S @dirlist=$H_","_$J_","_$I N R,Z,Lock Lock +@dirlist:1 S Lock=$T DO Lock:Lock -@dirlist Q R . N N,OLD,MAX,TWO S (N,MAX)=$G(@dirlist@(0))+1,TWO=0 Get . S OLD=$G(@dirlist@(N)),$ZT="GetErr" I OLD="",N=MAX S OLD=$G(d) . W:'TWO ! I TWO W $C(13),$J("",70),$C(13) ;start on new line . W p_": "_$S(OLD]"":OLD_" => ",1:"") R R S Z=$ZB,TWO=0 S:R="" R=OLD . i $ZM'["R" I $A(Z)=27 S R="" DO G Get:R="" ;handle special function keys!! . . I Z=$C(27,91,65) DO Q ;handle ANSI up-arrow . . . S TWO=1,N=N-1 I 'N S N=$G(@dirlist@(0))+1 Q . . I Z=$C(27,91,66) DO Q ;handle ANSI down-arrow . . . S N=N+1,TWO=1 I N>MAX S N=1 . . I Z=$C(27,91,67) S R="@" Q ;handle ANSI right-arrow --> edit . . I Z=$C(27,91,68) S R="@" Q ;handle ANSI left-arrow --> edit . ; . I R="@",OLD]"" S R=$$ED(OLD) ;use good-old replace/with editor . I $E(R)="?" S Z=R Q ;pass-on request for elaboration . i $$STOP(R) Q . S Z=$S(exists:$$CDOS(R),1:$$CDVL(R)) . I Z="" W *7," could not interpret '"_R_"'",! G:exists Get d g:Z="N" Get . . s Z=$$YN("Use this directory anyway") . Q ;needed to not enter 'GetErr' GetErr . S $ZT="",D="",TWO=0,N=$G(MAX) ; clear default . I $P($ZE,">")=" "_%L Q %L CDVL(R) N N S $ZE="",$ZT="ChkBad",N=$ZU(12,R,1) Q N CDE(R) N N S $ZE="",$ZT="ChkBad",N=$ZU(12,R,2) Q N CDOS(R) N N S $ZE="",$ZT="ChkBad",N=$ZU(12,R,3) Q N CD(R) N N S $ZE="",$ZT="ChkBad",N=$ZU(12,R,2) Q N ChkBad S $ZT="" W !,"<"_$P($P($ZE,"<",2),">")_"> error -- invalid directory" Q "" STOP(x) S x=$$UC($E(x,1,4)) Q (x["EXIT")!(x["STOP")!(x["QUIT")!(x["HALT")!($E(x)="^") ; ZZ ; 24.08.01 - 9 u 19 * Cache-r3.1.8