page@swan.ulowell.edu (Bob Page) (03/15/89)
Submitted-by: well!sirius (Mike Stilson) Posting-number: Volume 89, Issue 47 Archive-name: dos/fs/free.1 [Shows how much free space is left on your disk/s, like info. uuencoded executable enclosed. ..Bob] # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # readme # makefile # Free.c # Free.uu # This archive created: Wed Mar 15 10:39:03 1989 cat << \SHAR_EOF > readme Free (c) 1989 Mike 'Sirius' Stilson - Sirius Software Purpose of this program: I needed to know how much space was left on my disks. I wanted it in terms of Bytes, not blocks. And telling me x% free (ala Info) didn't help much. Usage: Free [Devices] If no argument is given, free gives info about the volume containing the current directory. The output is of the format: Volume Name: Bytes Per Block: Total bytes: Free Bytes: Total blocks: Free Blocks: Free can handle a list of devices. (Sorry.. no wildcards yet.) such as: Free Dh1: Dh2: Df0: Hope you enjoy it, and let me know of any problems. This compiles under Manx 3.6a Makefile is included. Mike 'Sirius' Stilson - Sirius Software uucp: sirius@well.UUCP or: ...portal!cup.portal.com!sirius SHAR_EOF cat << \SHAR_EOF > makefile CFLAGS= LFLAGS= all: Free.o ln $(LFLAGS) Free.o -lc SHAR_EOF cat << \SHAR_EOF > Free.c /* Free.c - (c) 1989 Mike 'Sirius' Stilson - Sirius Software * Ver1.0 January 1989. Written, Tested, Debugged, Re-Tested, and Finished. * * Display free/total bytes for a volume. * * Notice: * The author makes no claims or guarantees of the suitability of this * program for any given application, and I assume no responsibility or * liability for damages incurred through its usage. * * Feel free to steal any or all of this code and make millions of dollars * from its sale and commercial use, but please.. Give credit where credit is * due. * * Any similarity of this program, living, dead, deleted, or undead is purely * coincidental and unintentional. * */ #include <exec/types.h> #include <exec/memory.h> #include <libraries/dos.h> #include <libraries/dosextens.h> #include <functions.h> struct InfoData *idata = NULL; struct FileLock *mylock = NULL; _wb_parse() {} /* We don't run from the wb.. */ main(ac,av) int ac; char **av; { char *GetName(); if(!(idata=(struct InfoData *) AllocMem((long)sizeof(struct InfoData),(long)MEMF_CHIP|MEMF_CLEAR))) { puts("Not enough memory.\n"); exit(20); } if(ac==1) goto once; while(--ac > 0) { once: if(!(mylock=Lock(*++av,ACCESS_READ))) { printf("Attempt to lock %s failed.\n",*av); FreeMem(idata,(long)sizeof(struct InfoData)); exit(20); } if(!(Info(mylock,idata))) { printf(Output(),"Unable to obtain info for device %s.\n",*av); FreeMem(idata,(long)sizeof(struct InfoData)); UnLock(mylock); exit(20); } printf("Volume Name: \2334;31;40m%s\2330;0;0m\t",GetName(mylock)); GetFree(); UnLock(mylock); } FreeMem(idata,(long)sizeof(struct InfoData)); exit(0); } /* Macro to convert a BPTR to a CString. Just for readability */ #define BPTR_TO_C(cast, var) ((struct cast *)(BADDR((ULONG)var))) char * GetName(lock) struct FileLock *lock; { struct DeviceList *dl=NULL; register char *p=NULL; register char buf[80]; Forbid(); /* Since the InfoData structure points to a NULL BSTR all the time, this is the only way I can think to get the volume name */ lock = BPTR_TO_C(FileLock, lock); dl = BPTR_TO_C(DeviceList, lock->fl_Volume); p = (char *)BADDR(dl->dl_Name); movmem(p+1, buf, p[0]); buf[p[0]] = '\0'; Permit(); return(buf); } GetFree() { register ULONG usedbytes=0, totalbytes=0, freebytes=0, bpb=0; bpb=idata->id_BytesPerBlock; usedbytes=bpb * idata->id_NumBlocksUsed; totalbytes=bpb * idata->id_NumBlocks; freebytes=totalbytes-usedbytes; printf("Bytes per block: %-7ld\n",bpb); printf("Total bytes: %-7ld\t\tFree Bytes: %-7ld\n",totalbytes,freebytes); printf("Total blocks: %-7ld\t\tFree Blocks: %-7ld\n\n",idata->id_NumBlocks, (idata->id_NumBlocks - idata->id_NumBlocksUsed)); } SHAR_EOF cat << \SHAR_EOF > Free.uu begin 644 Free M```#\P`````````#``````````(```31````JP````$```/I```$T4[Z`U!.F M50``3EU.=4Y5``!(>``"2'@`)$ZZ$K!03RE`@`)F%$AZ`/9.N@+N6$\_/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R";D[N_\1.^@`"(B\`!"QL@FY.[O^F3.\`#@`$+&R";D[N_]!(B MYP$$3.\@@``,+&R":DZN_Y1,WR"`3G4B;P`$+&R":D[N_F).^@`"3.\``P`$U M+&R":D[N_SHB;P`$+&R":D[N_MI.^@`"+&R":D[N_WQ.^@`"(F\`!"`O``@L- M;()J3N[_+B!O``0L;()J3N[^C"QL@FI.[O]V(F\`!"QL@FI.[OZ&3.\``P`$N M+&R":D[N_LX@;P`$+&R":D[N_H```````^P````!`````0```\8````````#: M\@```^H```"8```````````P,3(S-#4V-S@Y86)C9&5F````("`@("`@("`@Y M,#`P,#`@("`@("`@("`@("`@("`@(""00$!`0$!`0$!`0$!`0$!`#`P,#`P,( M#`P,#$!`0$!`0$`)"0D)"0D!`0$!`0$!`0$!`0$!`0$!`0$!`4!`0$!`0`H*. M"@H*"@("`@("`@("`@("`@("`@("`@("0$!`0"```````````````````0``Q M```!``````````````````````$!`````0`````````````````````!`@``' M``$`````````````````````````````````````````````````````````! M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````````````````````````````````````` M````````````````````````````%`````````````````/R```#ZP````$`X #``/RU `` end size 5628 SHAR_EOF # End of shell archive exit 0 -- Bob Page, U of Lowell CS Dept. page@swan.ulowell.edu ulowell!page Have five nice days.