Month
Program Output Sample

Brief Information about the July 98 CSIG Meeting

Disk Drive Space Inventory by Bruce Arnold


This is the first of a multi part lecture on checking the space on your hard drive, etc. This section is designed to use the command window in windows9X or winNT.

Object: To inventory all file space used on a hard drive and display a sorted list of the top level sub directories and the total space occupied under each one. This is now a 32 bit application. Enhancements include the use of computed cluster sizes. (compiler: Microsoft VC++ 5.0 )

"Random Access" questions start at 7:30 Tuesday night. See you there.


You can get the source code and the executable programs from links on C User Group: The source code and executables will be available directly from the ACGNJ ftp server:

See SOURCE CODE links below.


Sample Code:

int main(int argc, char **argv)
    {
    char root[_MAX_PATH] = "\\", mytime[20], mydate[20];

    if (argc==1) { puts(VERSION); return 1; }

    _strdate(mydate); _strtime(mytime);

    CDiskInfo Homedrive;		// save startup info
    CPathInfo Target(argv[1]);		// parse command line argument

    
    // Attempt to change to new drive and check that is was successful.
    //
    if (Target.DKnumber <= 26) _chdrive(Target.DKnumber); // 1=A, 2=B, ...
    if (Target.DKnumber != _getdrive()) 
	    { puts("+++ Disk Selection Error +++\007"); return 2; }

    if (*Target.dir) strcpy(root,Target.dir);	// adjust root starting point

    CDiskInfo *Newdrive = new CDiskInfo();	// store info about new drive
    gCluster = Newdrive->Cluster;		// save value in global varable

    printf("; Drive   = %c:\n",		Newdrive->DKletter  );
    printf("; Path    = %s\n",		root		    );
    printf("; Cluster = %ld bytes\n",   Newdrive->Cluster   );
    printf("; Date    = %s %s\n",	mydate, mytime	    );

    search(root);				// Do a RECURSIVE file search

    printf("%6ld MB_used in %ld files (%ld folders)\n",
			    megabytes(Gsize), gFileCount, gFolderCount	);
    printf("%6ld MB_avail\n", (Newdrive->KBavail >> 10)			);

    delete Newdrive;			// Restore original settings.
    return 0;
    }


"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ b l a s t . n e t
Back to C++ Main Page