Skip to content

FlushFile

Narta Xaymar Dirks edited this page Dec 3, 2026 · 1 revision

FlushFile BlitzLLVM

FlushFile:Void stream:Int32
Parameter Mode Type Default Description
stream In Int32 required The stream, from WriteFile or OpenFile.

Description

BlitzLLVM This command does not exist in the original Blitz products. BlitzLLVM adds it.

Writes out what is still in the buffer of a file stream, so that the file has everything that was written to it so far. This is a BlitzLLVM extension.

What a program writes to a file from WriteFile or OpenFile is collected in memory and goes to the file in larger pieces, which is much faster than going to the disk for every line. It all reaches the file when the stream is closed with CloseFile or the program ends with End. If the program is ended from outside (by KillProcess, a signal, or the task manager) or crashes, what was still in memory is lost. FlushFile makes it reach the file now. Call it after lines that must survive, such as the lines of a log, or before another stream or program reads the file. It costs a write to the system each time, so don't call it after every line of a big file.

Streams without a buffer of their own (TCP and UDP streams, the streams of CreateProcess, std:out and std:err) have nothing to flush, and FlushFile does nothing with them.

Examples

log = WriteFile(SystemProperty$("cachedir") + "server.log")
WriteLine log, "Server started"
FlushFile log ; Even if the server is killed now, the line is in the file.

Related Commands

CloseFile BlitzBasic, CopyFile BlitzBasic, DeleteFile BlitzBasic, NextFile BlitzBasic, OpenFile BlitzBasic, ReadFile BlitzBasic, SeekFile BlitzBasic, WriteFile BlitzBasic

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

More

Clone this wiki locally