File module

file_flush

procedureSource

Asks the system to write the file's buffers to the device (FlushFileBuffers); returns false for a closed file or on an error.

file_flush :: (file: File) -> bool

Parameters

file: File

Returns

bool
Example
#import "Extensions/Environment";
base := environment_variable("TMPDIR");
if base == "" base = environment_variable("TEMP");
if base == "" base = "/tmp";
path := tprint("%/jai-doc-flush.bin", base);
defer file_delete(path);
file, ok := file_open(path, for_writing = true);
assert(ok);
defer file_close(*file);
assert(file_write(*file, "data"));
assert(file_flush(file));
text, read_ok := read_entire_file(path); // another reader sees it already
assert(read_ok && text == "data");
free(text);

Doesn't run in the browser (only on windows).

See also