finding free disk space

finding free disk space

Post by Bob Farrel » Wed, 21 Aug 1996 04:00:00



I am using Borland C++ v. 3.1 and want to find the free disk space on the hard
drive.  I'm writing a DOS program, which is being used in a Windows NT DOS session.
I have a 2 GB NTFS hard drive.

When I use getdfree(), it is supposed to return the number of available
and total clusters, bytes per sector, and sectors per cluster.  I've used
this function successfully on other systems, but it doesn't seem to be working
on this system.  It returns the following:

available clusters: 31249
total clusters:     31249
bytes per sector:     512
sectors per cluster:   64

This gives a total and available disk space of 1,023,967,232 bytes -- or about
half of what is on the disk.

chkdsk returns (on an NTFS drive):

  2096451 kilobytes total disk space.
   385313 kilobytes in 6858 user files.
     1444 kilobytes in 255 indexes.
    12010 kilobytes in use by the system.
  1697683 kilobytes available on disk.

      512 bytes in each allocation unit.
  4192902 total allocation units on disk.
  3395367 allocation units available on disk.

Can anybody give me any insights as to whether this discrepency is due to
the disk size being too large for the getdfree() function, or if it is due
to the NTFS file system?  

Any suggestions on how I can get the correct free disk space under these
circumstances?  (The program must work under any and all DOS sessions -- i.e.,
NT, Win95, real DOS.)

Thanks in advance,

Bob Farrell

Marquette Electronics, Inc.
Milwaukee WI

 
 
 

finding free disk space

Post by James Tinsl » Wed, 21 Aug 1996 04:00:00




Quote:>I am using Borland C++ v. 3.1 and want to find the free disk space on the hard
>drive.  I'm writing a DOS program, which is being used in a Windows NT DOS session.
>I have a 2 GB NTFS hard drive.

>When I use getdfree(),<snip>  It returns the following:

>available clusters: 31249
>total clusters:     31249
>bytes per sector:     512
>sectors per cluster:   64

>This gives a total and available disk space of 1,023,967,232 bytes -- or about
>half of what is on the disk.

>chkdsk returns (on an NTFS drive):
<snip>
>  1697683 kilobytes available on disk.

>Can anybody give me any insights as to whether this discrepency is due to
>the disk size being too large for the getdfree() function, or if it is due
>to the NTFS file system?  

Not a problem with getdfree(); I just ran it on a 2Gb DOS drive and
got the right result. (BTW I presume that you have a typo in the
"Total Clusters" figure above, since it is identical to your
"Available" figure.)

The difference is that NTFS does NOT waste a massive amount of space
by keeping rigidly to the formal 32K cluster size - it never wastes
more than 511 bytes per file. There's a call somewhere to deal with
this, but I can't remember it off the top of my head. Try any NTFS
techdocs you have available; it'll be featured prominently - good
points always are :-).

Best of luck with it
James

 
 
 

1. free disk space on large disks

Is there a way to get the real free disk space in a 16 bit program. I am
using _dos_getdiskfree to retrieve the disk space and the OS (NT4) changes
the sectors per cluster value to make the calculation
sectors_per_cluster*bytes_per_sector <= 65535.

Thanks Ian Marriott

2. Spareparts for Tektronix Phaser

3. Help finding how much free space is on HD???????

4. need help on PPC development

5. Help finding how much free space is on HD

6. Low network performence between w2k computers?

7. Free disk space from batch file

8. free disk space

9. How to exit a batch file if free disk space is eg less than 40Mb?

10. Free disk space from C, how please ??

11. Getting disk free space on FAT32 partition

12. Returning the amount of disk free space