FileFlush: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Portuguese version indexed) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server client function}} | ||
Forces pending disk writes to be executed. [[fileWrite]] doesn't directly write to the hard disk but places the data in a temporary buffer; only when there is enough data in the buffer it is actually written to disk. Call this function if you need the data written right now without closing the file. | Forces pending disk writes to be executed. [[fileWrite]] doesn't directly write to the hard disk but places the data in a temporary buffer; only when there is enough data in the buffer it is actually written to disk. Call this function if you need the data written right now without closing the file. This is useful for log files that might want to be read while the resource is still executing. [[fileFlush]] can be called after each log entry is written. Without this, the file may appear empty or outdated to the user. | ||
==Syntax== | ==Syntax== | ||
Line 8: | Line 8: | ||
bool fileFlush ( file theFile ) | bool fileFlush ( file theFile ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[file]]:flush}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 30: | Line 31: | ||
==See Also== | ==See Also== | ||
{{File functions}} | {{File functions}} | ||
[[pt-br:fileFlush]] |
Latest revision as of 18:14, 20 December 2023
Forces pending disk writes to be executed. fileWrite doesn't directly write to the hard disk but places the data in a temporary buffer; only when there is enough data in the buffer it is actually written to disk. Call this function if you need the data written right now without closing the file. This is useful for log files that might want to be read while the resource is still executing. fileFlush can be called after each log entry is written. Without this, the file may appear empty or outdated to the user.
Syntax
bool fileFlush ( file theFile )
OOP Syntax Help! I don't understand this!
- Method: file:flush(...)
Required Arguments
- theFile: The file handle of the file you wish to flush.
Returns
Returns true if succeeded, false in case of failure (e.g. the file handle is invalid).
Example
local fileHandle = fileCreate("test.txt") if fileHandle then fileWrite(fileHandle, "Line 1") fileFlush(fileHandle) -- ... further writing operations fileClose(fileHandle) end
Note that fileClose automatically flushes the file.