home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
dos
/
free2.lzh
/
FREE.DOC
< prev
next >
Wrap
Text File
|
1986-12-17
|
6KB
|
142 lines
-------------------------------------------------------------
| FREE v2.0 Display free disk space or RAM memory. |
| |
| ~~~~~~~ For the PUBLIC DOMAIN by Vince Bly ~~~~~~~~ |
| |
| Send comments, criticisms, and small contributions to: |
| Vince Bly, Nanosoft, P.O. Box 409, Ft. Belvoir, VA 22060 |
-------------------------------------------------------------
OVERVIEW
--------
FREE is a small utility that displays the free space on the
current or specified disk drive or free RAM memory. It can also
set the DOS errorlevel if the amount of free space/memory is less
than a specified amount. The command syntax is:
FREE [D[:]] [MINREQ] [+]
D is the drive letter of the disk whose free space is to be
checked. If D is "M" or "m", then the available free RAM memory
will be checked. The ":" may be included for consistancy with
other DOS commands, but will be ignored. That is, FREE C and
FREE C: are equivalent. If D is not equal to "M" or "m" and does
not correspond to a drive on your system, then the message
"** Invalid Drive **" will be displayed and the DOS errorlevel
will be set to 2.
MINREQ is the the minimum number of bytes you require. If
the actual number of bytes free is less than MINREQ, then FREE
will set the DOS errorlevel to 1. This can be used to control
the flow of a batch file.
The plus sign (+) is used to indicate that more detailed data
is desired. If detailed data is requested for a disk drive, the
information will include: the sectors per cluster, the bytes per
sector, the bytes per cluster, the total clusters, the free
clusters, the total bytes, and the free bytes. If detailed data
is requested for RAM, the information will be: the next free
address, the top address, and the number of free bytes. In
either case, the decimal values will be displayed followed by
their hexadecimal equivalents.
Any (or all) options may be omitted and those included may be
in any order. However, all options must be separated by spaces.
EXAMPLES
--------
FREE displays free space on current drive.
FREE A displays free space on drive A.
FREE C: displays free space on drive C.
FREE B + display detailed information for drive B.
FREE M displays free RAM memory.
FREE 50000 displays free space on current drive & sets errorlevel
to 1 if less than 50,000 bytes are available.
FREE M 256000 displays free RAM & sets errorlevel 1 if < 256K free.
SAMPLE USE IN A BATCH FILE
--------------------------
echo off
free m 128000
if errorlevel 1 goto tag1
bigprog
goto tag2
:tag1
echo ** Not Enough Memory to run BIGPROG **
:tag2
This example assumes that you have some program "bigprog"
that requires, at least, 128k of free RAM to run successfully.
The batch file line free m 128000 determines the amount of free
RAM memory and sets the DOS errorlevel to 1 if less is available.
Therefore, the batch file executes bigprog only if there's enough
memory; otherwise it gives an error message.
DETAILED DATA OUTPUT
--------------------
If you issued the command FREE C + the output might be like
that shown below. This data is discussed in the TECH. NOTES
section on the next page.
Drive C:
Sectors/cluster = 16 [0010]
Bytes/sector = 512 [0200]
Bytes/cluster = 8,192 [2000]
Total clusters = 2,591 [0A1F]
Free clusters = 49 [0031]
Total bytes = 21,225,472 [143E000]
Free bytes = 401,408 [62000]
If you issued the command FREE M + the output might be like
that shown below. This data is also discussed in TECH. NOTES.
RAM memory:
Next free addr = 417,856 [660A0]
Top address = 655,359 [9FFFF]
Free bytes = 237,504 [39FC0]
TECH. NOTES
-----------
All FREE output goes through DOS to the standard output
device. Therefore, FREE's output can be re-directed.
FREE requires approximately 8K of memory to run. If less
is available, the system will probably crash (the crash occurs
during C initialization, before the C code can do anything about
it). The amount of free RAM displayed is corrected for the RAM
space used by FREE itself.
The detailed output for disk drives includes the bytes per
cluster (sectors/cluster * bytes/sector). This cluster size is
the "quantum" of disk space usage. The space used by a file will
always be an integer multiple of the bytes per cluster. In the
example shown above, the minimum space used by any file will be
8196 bytes. Note that the "size" listed by DIR for a file is the
actual data size, not the amount of disk space used.
The detailed output for RAM memory displays the next free
address, the address of the lowest unused memory location. This
is where the Program Segment Prefix (PSP) of the next loaded
program would start. In the example above, the PSP would start
at address 660A0 or, in segmemt:offset form 660A:0000. The top
address is the highest RAM memory address. Note that FREE does
not examine extended memory (EMS/EEMS). Therefore, the value of
top address will aways be less than or equal to 9FFFF (640K).
I have included the source code (in DeSmet C) with liberal
comments. The method of determining free RAM has been greatly
simplified compared to an earlier version of FREE which used
the DOS SETBLOCK function. You are welcome to incorporate any
of the routines in FREE in your own programs. VB. 12/17/86