flush


Description:

[ CCode ( cname = "fflush" ) ]
public int flush ()

Causes the output file stream to be synchronized with the actual contents of the file.

If the given stream is of the input type, then the behavior of the function is undefined.

Example: Flush the stream:

public static int main (string[] args) {
// open a file:
FileStream stream = FileStream.open ("test.txt", "w+");
assert (stream != null);

// write some data
stream.puts ("some data\n");

// make sure data is written to our file:
stream.flush ();

// read the data:
stream.rewind ();
string str = stream.read_line ();
assert (str != null);

print ("'%s'\n", str);

return 0;
}

valac --pkg glib-2.0 GLib.FileStream.flush.vala

Returns:

Returns zero on success. Otherwise EOF is returned and the error indicator of the file stream is set.