home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 6 File
/
06-File.zip
/
DIRSIZE.ZIP
/
DIRSIZE.C
next >
Wrap
C/C++ Source or Header
|
1990-12-27
|
3KB
|
101 lines
#define INCL_DOSFILEMGR
#define INCL_DOSPROCESS
#include <os2.h>
#include <stdio.h>
/******************************************************************
The FILEFINDBUF structure.
Field Description
────────────────────────────────────────────────────────────────────────────
fdateCreation Specifies the date the file was created.
ftimeCreation Specifies the time the file was created.
fdateLastAccess Specifies the date the file was last accessed.
ftimeLastAccess Specifies the time the file was last accessed.
fdateLastWrite Specifies the date the file was last written to.
ftimeLastWrite Specifies the time the file was last written to.
cbFile Specifies the end of file data.
cbFileAlloc Specifies the allocated file size.
attrFile Specifies the file attributes.
cchName Specifies the length of the null-terminated filename.
achName[CCHMAXPATHCOMP] Specifies the null-terminated filename.
The FDATE structure is used in various other structures to specify the day,
month, and year.
_FDATE {
unsigned day : 5;
unsigned month : 4;
unsigned year : 7;
} FDATE;
Field Description
────────────────────────────────────────────────────────────────────────────
day Specifies the day.
month Specifies the month.
year Specifies the year.
*****************************************************************************/
void cdecl main ( int argc, char *argv[] )
{
HDIR hdir;
USHORT usSearch;
FILEFINDBUF findbuf;
USHORT Error = 0;
ULONG allocated_dirsize = 0;
ULONG actual_dirsize = 0;
hdir = HDIR_SYSTEM;
usSearch = 1;
if (argc < 2 )
{
printf("\nUsage: DIRSIZE filename.ext\n");
printf("wildcard \"*,?\"characters are OK");
DosExit(0,0);
}
Error = DosFindFirst (argv[1],
&hdir,
FILE_NORMAL,
&findbuf,
sizeof(findbuf),
&usSearch,
0L);
if (Error != 0)
{
printf("USAGE: DIRSIZE filespec.ext");
DosExit(0,0);
}
else
{
printf("%s \t%lu\t%lu\t%2d-%2d-%2d\n",
findbuf.achName,
findbuf.cbFileAlloc,
findbuf.cbFile,
findbuf.fdateLastWrite.month,
findbuf.fdateLastWrite.day,
findbuf.fdateLastWrite.year+80);
allocated_dirsize += findbuf.cbFileAlloc;
actual_dirsize += findbuf.cbFile;
}
do
{
usSearch = 1;
Error = DosFindNext (hdir, &findbuf, sizeof(findbuf), &usSearch);
if (Error == 0)
{ /* _dos_findnext */
printf("%s \t%lu\t%lu\t%2d-%2d-%2d\n",
findbuf.achName,
findbuf.cbFileAlloc,
findbuf.cbFile,
findbuf.fdateLastWrite.month,
findbuf.fdateLastWrite.day,
findbuf.fdateLastWrite.year+80);
allocated_dirsize += findbuf.cbFileAlloc;
actual_dirsize += findbuf.cbFile;
}
} while (usSearch != 0);
printf("\nAllocated Directory Size: %lu bytes - Actual Directory Size: %lu bytes.\n",allocated_dirsize, actual_dirsize);
DosFindClose (hdir);
}