WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

DiskFree Allocation Size, Large Drives, and How to Return a Value in MB

Keywords:	 disk free diskfree allocation size space file

Question:

How does the diskfree function work? I've moved some files from a diskdrive, and then am checking how much disksize is free using the Diskfree function, but it doesn't seem to be reporting the new value.

Answer:

DiskFree returns free space for new files.

If you run a DiskFree on a new disk, it returns the space on the disk. If you move some files over and subtract their size from the original disk space, the sum will not necessarily be what DiskFree returns after the files have been moved.

Files are allocated a certain amount of space regardless of their size. For example, if you have a ream of paper, which is 500 sheets, and you write 2 letters, one letter is 1-1/2 pages and the other page is 1/2 a page. You may think that you have 498 pages remaining, when in fact you have 497 pages remaining. If you write on 1/2 a page, you have still used one page.

So you need to figure out the size of the file and then bump it up to the next allocation size. Then add up the allocation sizes of all the files to get the correct amount.


Additional Questions about Large Disk Drives:

I am using WinBatch 5.1C WIL Version 2.2abg in both the 16 and 32 bit environments.

In the 16 bit environment, I am doing an addextender of "wwwn16i.dll" and using "wnaddcon" and "wncancelcon" to connect and disconnect. Diskfree never reports more than 2,147,483,647 free, even though the server connected to has more than 8Gb free. In general I need to be able to handle numbers into the 100+Gb range.

In the 32 bit environment, I am doing an addextender of "wwnet34I.dll" and using "netadddrive" and "netcancelcon" to connect and disconnect. Diskfree is never called, because I don't get a connection.

Answer:

Results lager than 2 gigabytes will be returned as a floating point number. However, it should be noted that in Windows 95 prior to OSR 2 incorrect values may be returned for volumes larger than 2 gigabytes.

The number you are getting is the largest positive number that will fit into our integer variables (32 bit signed).

I checked with the current version 96G and when the diskfree space gets larger than that, we move into floating point mode. But in 5.1C, I don't exactly remember how diskfree operated. So one of the two items below is occurring:

  1. 5.1C does not move into floating point mode and simply returns the largest 32 bit integer.
  2. The network server OS is returning a 32 bit max size integer when queried about its disk space. This is very common with older network versions that existed before the new multigigabyte hard drives came out.
I suspect it is #2. The following test might show it:
	aaa=DiskFree("C: C: C: C: C: C: C: C: C: C: C: C: C: C: C: C: C: C: C: C: C:")
	Message("C: etc",aaa)  

In this example we just check the freespace on the C: drive a lot. Hopefully there is a lot of free space on it and the number will get large. The idea is to see if it moves into floating point land or not.


Question on How to Convert Returned Value to MB:

Diskfree reports the size of the drive in bytes. I would like the size to be reported in Megabytes.

I've written a simple script:

sz = Diskfree("c")
Display(5, "Size", "The size of your drive is: %sz% MB)
The size of the drive appears in bytes, ie. 678260736 btyes but I want it to appear as 678 MB. How do you do conversion?

Answer:

  1. Determine how big a megabyte is. There are three schools of thought.

    • MB=1000*1000 ; Decimal school
    • MB=1024*1000 ; Intermediate School
    • MB=1024*1024 ; Binary School

  2. Then...
    MB=1024*1024
    sz = Diskfree("c")
    szmb= Int(sz / MB)
    
    Display(5, "Size", "The size of your drive is: %szmb% MB)

Article ID:   W13052
Filename:   DiskFree Function.txt
File Created: 2001:03:01:14:41:36
Last Updated: 2001:03:01:14:41:36