hb_DiskSpace() Shows Incorrect Value
Moderator: Rathinagiri
-
melliott42
- Posts: 119
- Joined: Wed Feb 18, 2009 2:14 pm
hb_DiskSpace() Shows Incorrect Value
Hello,
In Windows XP and 7 if I issue the function hb_DiskSpace('C:', HB_DISK_FREE) the value returned is not the same found in the Windows GUI interfaces.
Which one is correct?
If it is Windows what can we do to return the right value?
Thanks,
Michael
In Windows XP and 7 if I issue the function hb_DiskSpace('C:', HB_DISK_FREE) the value returned is not the same found in the Windows GUI interfaces.
Which one is correct?
If it is Windows what can we do to return the right value?
Thanks,
Michael
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: hb_DiskSpace() Shows Incorrect Value
What is right value and where is their source?melliott42 wrote: Which one is correct?
If it is Windows what can we do to return the right value?
Regards
--
Esgici
Viva INTERNATIONAL HMG 
- Rathinagiri
- Posts: 5481
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: hb_DiskSpace() Shows Incorrect Value
There are two sizes for each file.
The actual file size and the size on disk. Whether that might be the cause of this problem?
Just my two cents...
The actual file size and the size on disk. Whether that might be the cause of this problem?
Just my two cents...
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
-
melliott42
- Posts: 119
- Joined: Wed Feb 18, 2009 2:14 pm
Re: hb_DiskSpace() Shows Incorrect Value
Thanks for pointing this out guys.
Re: hb_DiskSpace() Shows Incorrect Value
Really interesting observation!
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: hb_DiskSpace() Shows Incorrect Value
rathinagiri wrote: There are two sizes for each file.
The actual file size and the size on disk.
If you have a diskette drive on your PC, you can do this test:swapan wrote:Really interesting observation!
Code: Select all
copy con test1.txt // I'll write someting on console, save it to a file name is : test1.txt
1^Z // write only one character ("1") and than press ^Z (EOF) (or press F6)
// this terminate writing and save the file
dir // show me list of files on this folder ( A:\ )
... // some info about disk
...
06.08.2010 14:58 1 test1.txt
1 file 1 byte
0 folder 1.457.152 bytes free
Code: Select all
copy con test2.txt
1^Z
dir
... // some info about disk
...
06.08.2010 14:58 1 test1.txt
06.08.2010 14:58 1 test2.txt
2 file 2 byte
0 folder 1.456.640 bytes free
1.457.152 - 1.456.640 = 512 is space occupied on disk by each 1 byte file.
This is because OS allocates disk space to file as 512 byte unites per request. FE if file size is 513 byte, allocated space will be 1024 bytes.
This is for FAT16 file system and for relatively small media (diskette in our example). While media grown, this allocation unit size too will be greater.
In NTFS, file allocation system is totally different and more complicated.
Regards
--
Esgici
PS: This little information dedicated to who search always a "tool" for every need.
Last edited by esgici on Fri Aug 06, 2010 1:01 pm, edited 1 time in total.
Viva INTERNATIONAL HMG 
- Rathinagiri
- Posts: 5481
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: hb_DiskSpace() Shows Incorrect Value
This is called the cluster size. 
Thanks Esgici for the efforts.
Thanks Esgici for the efforts.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: hb_DiskSpace() Shows Incorrect Value
Yes, "allocation unit" is called sometime "cluster";rathinagiri wrote:This is called the cluster size.
thanks Rathi
Regards
--
Esgici
Viva INTERNATIONAL HMG 
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: hb_DiskSpace() Shows Incorrect Value
BUT !
"Cluster" concept doesn't reason of difference between DOS command result and "Disk Properties" report of Windows.
Sadly, I don't know this reason
Does anyone know ?
Regards
--
Esgici
"Cluster" concept doesn't reason of difference between DOS command result and "Disk Properties" report of Windows.
Sadly, I don't know this reason
Does anyone know ?
Regards
--
Esgici
Viva INTERNATIONAL HMG 
Re: hb_DiskSpace() Shows Incorrect Value
Hello,
IMHO, dir command calculates SIZE OF THE FILE and Disk property calculates SIZE OF THE FILE ON THE DISK (ie., amount of disk space being occupied).
So, what's the difference?
Size is the actual size of the file in bytes.
Size on disk is the actual amount of space being take up on the disk.
The disk is broken down into tracks and sectors.
So, if your sector size is 512 bytes and your file is actually 513 bytes, the size on disk will be 1024bytes because it is occupying two sectors.
(taken from http://answers.yahoo.com/question/index ... 416AAzMmNu)
IMHO, dir command calculates SIZE OF THE FILE and Disk property calculates SIZE OF THE FILE ON THE DISK (ie., amount of disk space being occupied).
So, what's the difference?
Size is the actual size of the file in bytes.
Size on disk is the actual amount of space being take up on the disk.
The disk is broken down into tracks and sectors.
So, if your sector size is 512 bytes and your file is actually 513 bytes, the size on disk will be 1024bytes because it is occupying two sectors.
(taken from http://answers.yahoo.com/question/index ... 416AAzMmNu)
With best regards,
Sudip
Sudip