home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 6 File
/
06-File.zip
/
dircount.zip
/
README.DCT
< prev
Wrap
Text File
|
1994-06-01
|
4KB
|
110 lines
DIRCOUNT - retrieve size of a directory, including all sub-directories.
How to Use
----------
From an OS/2 command prompt, enter the command in the following format:
DIRCOUNT [d:] directory-name [\subdirectory] [\subdirectory]...
Drive letter is optional, unless you're in a sub-directory which is not a parent
to the directory for which you're retrieving the size.
See the section "Examples" for... well... examples.
What it does
------------
DIRCOUNT simply rolls through a directory, adding up the size of each file
it encounters. If the file happens to be a sub-directory, THAT sub-directory
is then switched to, and all files are read and added into the total. If
any sub-directories are encountered in a sub-directory, THOSE are read
and added in to the total. When the directory and all sub-directories have
been read, the size is reported.
I just re-read that last paragraph, and have the feeling I overused the
word "sub-directory."
Only one function in the entire program reads directories and adds up the
file sizes. It is called recursively every time another sub-directory is
encountered. I'm taking advantage of the C-language characteristic that does
not preserve variables when a function is entered, even if called recursively.
My mom always said I was clever (then again, she also thinks I'm cool...).
Examples:
--------
From the C: root directory, retrieve the size of the OS2 directory:
"dircount os2 <cr>" or "dircount c:\os2 <cr>"
From the root directory, retrieve the size of the OS2\MDOS directory:
"dircount os2\mdos <cr>" or "dircount c:\os2\mdos <cr>"
From the OS2\MDOS directory, retrieve the size of the full OS2 directory:
"dircount c:\os2 <cr>"
If entered without the "c:\", you will get a message stating the directory
cannot be found.
By the way, the command "dircount c:\" won't work for some reason (the reason
most likely is that there is a bug), but, what the hey, if you want the entire
directory you can do a CHKDSK.
Why I wrote it
--------------
2 reasons: 1) When I needed the size of a full directory, I got sick of
having to change to all directories, using the "dir" command and adding
everything up from there; and 2) I recently started learning C language, and
I wanted to bang out a program as part of the learning process.
Other Stuff
-----------
I placed this in the public domain because, mainly, it's a dinky little
utility with no hope of sale value. But I've downloaded my share of freeware
from BBS's, plus a lot of the programmers had the decency to include source
code (from which I've been able to learn), so I don't mind giving back.
The code is there for you. Use it, learn from it. I'll check my mail infrequently
if you have any questions.
This utility will run in OS/2 only. I've tested it on various machines in
my own installation, and it's worked on everything from the IBM ValuePoint to
an IBM PS/2 57/76/80, as well as compatibles. Even on machines with 386 and
486 chips (but you're probably too young to remember those).
This was compiled using WATCOM C/C++32 vsn 9.5. The compiler performs various
optimization routines, so the executable usually runs pretty quick and clean.
Legal Stuff
-----------
This program is distributed as is, WITHOUT ANY WARRANTY. Use it at your
own risk (which, I believe, is minimal).
This is free software, it has been placed in the public domain. The code
included may be used in another program or modified, but if you do this,
do me a favor and take my name off it. The ZIP file containing the source,
executable and this readme may be distributed free of charge to anyone, anywhere,
any time, and any other "any's" I forgot.
By using this you agree not to hold me responsible for any problems encountered
while using DIRCOUNT, whether in executable format or in using the source code
for other programs.
Steve Warshaw