Page 1 of 1

How to flush a file data into disk? [SOLVED]

Posted: Sun Feb 11, 2007 1:35 am
by SkyManager
Using PB3.94 on my Red Hat 9, I create and write data to a text file on hard disk.

But until I perform a CloseFile procedure or exit the program, the data has not yet written to the file :!:

Is there a Flush function or similar procedure to use :?:

Posted: Sun Feb 11, 2007 8:16 pm
by bembulak
No, no flush function at the moment - but a good Idea!

Basically: what stops you from quickly write to file / close file and reopen it? The text in a stringvar e.g. an editor gadget gets not lost.

Posted: Sun Feb 11, 2007 8:19 pm
by AND51
In PB 4.0 there is explicitly a FlushFileBuffers() function. Maybe you can download the new PB version?

My other advise would be, to use gnozals PureFile lib... Maybe this one works?

Posted: Mon Feb 12, 2007 3:00 am
by SkyManager
The procedure I am using is for a text logger to record all activities, errors and event history.
The log file handler is rarely close itself and reopen again until the file reaches certain size, say 10MB, it will close itself and create a new log file.

At this moment, I can only doing a stupid thing - every 10 log writes, it will close itself and re-open itself so that the data can be flushed to disk.

I am using version 3.94. I guess this is the latest version for Linux.
Cannot rely on PB4-Linux as they are all still buggies.
:evil:

Posted: Mon Feb 12, 2007 10:55 am
by bembulak
In PB 4.0 there is explicitly a FlushFileBuffers() function. Maybe you can download the new PB version?
I should read the Help more carefully!

Thanks.

Posted: Mon Feb 12, 2007 3:11 pm
by AND51
No Problem :wink: