nn::fs::FileStream::Write Member Function

Syntax

virtual s32 Write(
     const void * buffer,
     size_t size,
     bool flush
);

Parameters

Name Description
in buffer Pointer to the buffer that contains the data to write.
in size Maximum number of bytes to write to the file.
in flush Specifies whether to flush data.

Return Values

Returns the actual number of bytes that were written.

Description

Writes the specified amount of data from a buffer to a file.

Up to size bytes of data are written to the file from the region at the address specified by buffer.

Data is not flushed if false is specified for flush. If multiple writes to the same file are to be made consecutively, call the TryFlush function after making all writes with flush = false. Then create a buffer to be managed by the system in low-level storage.

Do not write-access the memory of the specified buffer region during this function call (for example, from another thread). File writes may be incorrect and the program could stop working in a future version of the SDK.

This function is implemented to show an error screen when errors occur internally, whether or not such errors are fatal. Control does not return from the function in this case. Use nn::fs::FileStream::TryWrite on everything other than ROM archives.

To read details about error handling, see Handling Errors During File and Directory Operations.

Revision History

2011/03/18
Explained limitations on buffer access while calling this function.
2010/12/24
Added a link to the error handling page.
2010/10/05
Corrected the text.
2010/01/29
Initial version.

CONFIDENTIAL