Silverfrost Forums

Welcome to our forums

Best way to add data to the growing file

14 Sep 2010 11:58 #6939

Dan, Are you trying to find the free space, then try this program which has a couple of methods.

winapp
include <windows.ins>
logical*4 status
integer*8 BytesAvailableToCaller, TotalBytes, FreeBytes
integer*8 lpSectorsPerCluster8, lpBytesPerSector8, lpNumberOfFreeClusters8, lpTotalNumberOfClusters8

STDCALL GETDISKFREESPACEEX 'GetDiskFreeSpaceExA' (STRING,REF,REF,REF):LOGICAL*4

! First version for small disks < 2GB
status = GETDISKFREESPACE('c:\',lpSectorsPerCluster,    &
                               lpBytesPerSector,       &
                               lpNumberOfFreeClusters, &
                               lpTotalNumberOfClusters)
print *, status,lpSectorsPerCluster,    &
                lpBytesPerSector,       &
                lpNumberOfFreeClusters, &
                lpTotalNumberOfClusters
lpSectorsPerCluster8     = lpSectorsPerCluster
lpBytesPerSector8        = lpBytesPerSector
lpTotalNumberOfClusters8 = lpTotalNumberOfClusters
lpNumberOfFreeClusters8  = lpNumberOfFreeClusters              
TotalBytes=lpSectorsPerCluster8*lpBytesPerSector8*lpTotalNumberOfClusters8
print *,'Totalbytes',TotalBytes
FreeBytes=lpSectorsPerCluster8*lpBytesPerSector8*lpNumberOfFreeClusters8
print *,'Freebytes ',FreeBytes

!alternative version for large disks > 2GB requires STDCALL declaration above
status = GETDISKFREESPACEEX('c:\',BytesAvailableToCaller, &
                                  TotalBytes,             &
                                  FreeBytes)
print *, status,BytesAvailableToCaller, &
                TotalBytes,             &
                FreeBytes
end

Regards Ian

15 Sep 2010 12:01 #6940

Thanks John and Ian for ideas and solutions, they are very different valuable approaches.

As to the cissue, John, it is not completely clear to me yet when it issues an error status and when it does not. Definitely though when i heavily debugged it some time ago i've seen one case, i forgot right now exact details, will edit this post when remember, when i'd expect it to issue an error but it did not. So the idea is to get rid of it and use all other alternatives, may be even all of them for reliability

16 Sep 2010 8:56 #6945

Ian, do i have to use both functions for arbitrary large partitions or just the second is enough?

16 Sep 2010 11:00 #6947

Just the second

17 Sep 2010 2:04 #6955

Ian,

The first call will give details for a disk of up to 8 terrabytes ! I think that is still a big disk. Viewing the files will be an issue as Notepad struggles with files approaching 1gb. My line editor reads much quicker but tops out at 1.6gb (win32 again!!)

Incidently, your programing example sent me looking through the include files in the ftn95\include directory. Looking at the .ins files has driven me to writing a converter from 72 character fixed to 132 character free format so I can see the routine names and aliases as lists. It makes what looked like machine code look more readable.

John

19 Nov 2010 11:44 #7141

I know this one is a bit old now but it struck me at the time a more abstracted way of doing this would be to use a real database management system for data storage.

You would then use your favourite database communication technology to talk to the database.

The advantages are this. The people who have built the DBMS (microsoft, oracle) whoever have done lots of research into optimal database read write stuff, data integrity allow multi user access to data etc, etc.

The database can be put on a dedicated server and 1GB is a tiny database so will DBMS will make mince meat of it. eg SQL Server Express (free software) allows databases up to 12GB in size. DB2 is similar I believe. Don't know about MySQL.

Just a thought

Carl

Please login to reply.