# FS_WriteFileAsync

## C Specification

  `#include <nitro/fs.h>`
  `s32 FS_WriteFileAsync(FSFile* p_file, const void *src, s32 len);`

## Arguments

p_file | Address of the `FSFile` structure
src | Address of the buffer that stores the write data
len | Byte length of data to be written.

## Return Values

Returns the number of bytes if the data can be written properly. If not, returns `-1`.

## Description

This function asynchronously writes data of the specified size beginning at the current location of the file pointer. When the specified size is greater than the available memory, data is written until the available memory is used up. The size of the written data is returned. Unlike the `FS_WriteFile` function, it returns the control immediately and starts the asynchronous execution. Use the `FS_IsBusy` function to confirm the completion of the process. Alternatively, use the `FS_WaitAsync` function to wait for the completion.

## Note

If the archive cannot execute the asynchronous process with this function, it becomes the synchronous process, like the `FS_WriteFile` function. For such archives, this function cannot be called from the interrupt handler (IRQ mode). Note that the process may not be completed if interrupts are prohibited.

## See Also

`FSFile, FS_WriteFile, FS_IsBusy, FS_WaitAsync, FS_GetLength, FS_GetPosition, FS_SeekFile, FS_SeekFileToBegin, FS_SeekFileToEnd`

## Revision History

11/02/2004 Corrected name of argument.
09/24/2004 Added the description in the Caution section regarding the conditions for calling this function.
07/13/2004 Initial version.