{{newin|[[0.9.0]]|090|type=function}}
Sets the buffer mode for a file opened for writing or appending. Files with buffering enabled will not write data to the disk until the buffer size limit is reached, depending on the buffer mode.

[[(File):flush|File:flush]] will force any buffered data to be written to the disk.
== Function ==
=== Synopsis ===
<source lang="lua">
success, errorstr = File:setBuffer( mode, size )
</source>
=== Arguments ===
{{param|BufferMode|mode|The buffer mode to use.}}
{{param|number|size (0)|The maximum size in bytes of the file's buffer.}}
=== Returns ===
{{param|boolean|success|Whether the buffer mode was successfully set.}}
{{param|string|errorstr (nil)|The error string, if the buffer mode could not be set and an error occurred.}}
== See Also ==
* [[parent::File]]
* [[(File):getBuffer|File:getBuffer]]
* [[(File):write|File:write]]
* [[(File):flush|File:flush]]
[[Category:Functions]]
{{#set:Description=Sets the buffer mode for a file opened for writing or appending.}}
== Other Languages ==
{{i18n|(File):setBuffer}}