Re: show drive space used?
- Posted by rolf at rschr.de Aug 23, 2003
- 426 views
Peter Willems wrote: >=20 > rolf at rschr.de wrote: >=20 > > Hi Dan > > > > do you mean this kind of program? > > > > Have a nice day, Rolf > > > > ps: right clicking on a DIR under the Win explorer will also show you > > the content of the DIR and sub dirs. >=20 > I bet the program you are talking about was attached to your > message, posted from a mail client. So this is yet another > great feature of Topica (NOT!): it strips attachments so messages > like yours doesn't make any sense when using Topica's web > interface. Peter, you are absolutely right! Therefor I sent the attachment additionally directly to Dan's address. And I include it now directly into this mail . . . . Have a nice day, Rolf Start of EU code: ---------------------------------------------------------------------------= -- -- Rolf Schr=F6der 2003-= 07-6 --> DIRSIZE.EXW Content of DIR and all SUBDIRs. M=F6=F6rkenweg 37 -- =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF = 21029 Hamburg, Germany -- Language: EUPHORIA ver. 2.3 rolf at rschr.de ---------------------------------------------------------------------------= --- without type_check include file.e -- dir(), current_dir(), chdir() include get.e -- wait_key() include graphics.e -- get_position(), cursor() ---------------------------------------------------------------------------= --- integer rotnum -- needed for procedure rotator() sequence rotchar -- needed for procedure rotator() sequence keep_cuspos -- needed for procedure rotator() rotnum =3D 0 rotchar =3D {'-','\\','|','/'} procedure rotator() -- Needs local sequence keep_cuspos, -- =AF=AF=AF=AF=AF=AF=AF local initialized integer rotnum= , and -- local initialized sequence rotchar, i.e.: -- -- rotnum =3D 0 -- rotchar =3D {'-','\\','|','/'} -- keep_cuspos =3D get_position() -- position of 'normal' outpu= t rotnum =3D remainder(rotnum + 1,length(rotchar)) puts(1,rotchar[rotnum + 1]) position( keep_cuspos[1], keep_cuspos[2]) -- return to initial cuspos end procedure ---------------------------------------------------------------------------= --- function dirsize(sequence rootdir) -- Returns sum of all file sizes=20 -- =AF=AF=AF=AF=AF=AF=AF from rootdir and all s= ubdirs. object x sequence s atom bytes =20=20=20=20 if rootdir[length(rootdir)] !=3D '\\' then=20=20=20=20 rootdir &=3D '\\' -- Append '\\' at end of DIR string end if x =3D dir(rootdir & "*.*") -- Get DIR information of all files= =20 bytes =3D 0 if sequence(x) then -- Exclude forbidden DIRs for i =3D 1 to length(x) do -- Loop through DIR content s =3D x[i] if find('d',s[2]) then -- Check for SubDIRs if not (equal(s[1],".") or equal(s[1],"..")) then bytes +=3D dirsize(rootdir & s[1]) end if else bytes +=3D s[3] -- Sum Bytes!=20 end if end for end if rotator() -- Activity indicator if get_key() =3D 27 then -- Choice to abort=20 cursor(UNDERLINE_CURSOR) puts(1,"Aborted by ESC-key. Press any key . . .") x =3D wait_key() abort(0) end if return bytes end function ---------------------------------------------------------------------------= --- procedure main() -- =AF=AF=AF=AF=20=20 integer k atom bytes, a sequence s, rootdir =20=20=20=20 s =3D command_line() if length(s) < 3 then -- No dir given rootdir =3D current_dir() else -- Dir given via parameter rootdir =3D s[3] end if k =3D chdir(rootdir) if k then -- Dir exists rootdir =3D current_dir() else -- Dir doesn't exist puts(1,"Couldn't find \"" & rootdir & "\". Abort.\n\n") puts(1," press any key . . .") k =3D wait_key() return end if if rootdir[length(rootdir)] !=3D '\\' then -- Dir should end with '\= \' rootdir &=3D '\\' end if puts(1,"Size of \"" & rootdir &=20 "\" (All visible FILEs/SUBDIRs. Abort by ESC.):\n\n") cursor(NO_CURSOR) bytes =3D dirsize(rootdir) cursor(UNDERLINE_CURSOR) printf(1,"%d Bytes",bytes) s =3D {"KB","MB","GB","TB"} for i =3D 1 to 4 do a =3D power(1024,i) if bytes >=3D a then printf(1," =3D %.3f %s",{bytes/a,s[i]}) else exit end if end for puts(1,"\n\n press any key . . .") k =3D wait_key() end procedure ---------------------------------------------------------------------------= --- main() abort(0) ---------------------------------------------------------------------------= --- End of EU code.