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

Linux specific forum
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

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

Post 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 :?:
Last edited by SkyManager on Tue Mar 27, 2007 10:24 am, edited 1 time in total.
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 576
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post 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.
cheers,

bembulak
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post 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?
PB 4.30

Code: Select all

onErrorGoto(?Fred)
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Post 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:
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 576
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post 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.
cheers,

bembulak
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

No Problem :wink:
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Post Reply