# FS_WriteFile

## Syntax

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

## Arguments

file | FSFile structure that indicates an opened file.
src | Transfer source buffer There is no need to store the cache in advance.
len | Byte length of data to be written.

## Return Values

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

## Description

This function 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. The standard archives whose size can be increased automatically are the SD memory card archive and the NAND archive for NAND applications.
The size cannot be increased automatically for standard archives other than these.

## Note

- This function puts the thread to sleep to wait for the process to complete. As a result, it cannot be called from the interrupt handler (IRQ mode).
- In some cases, processing may not end if interrupts are left prohibited.

## See Also

`FS_CloseFile
FSFile
FS_GetFileLength
FS_OpenFileEx
FS_OpenFileFast
FS_SeekFile
FS_SeekFileToBegin
FS_SeekFileToEnd`

## Revision History

2009/12/11 Revised the archives whose size can be increased automatically.
2009/12/01 Clarified which archives can be automatically increased in size.
2008/10/02 Updated part of the See Also list.
2008/02/27 Explained that cache storage of write data is unnecessary.
2004/09/24 Added the description in the Caution section regarding the conditions for calling this function.
2004/07/13 Initial version.

CONFIDENTIAL