# 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. Depending on the implementation of the archive, the size may be expanded automatically.

## 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

2008/10/02 Updated the See Also list.
2008/02/27 Added the fact that cache doesn't have to be stored for the data being written.
2004/09/24 Added the description in the Caution section regarding the conditions for calling this function.
2004/07/13 Initial version.

CONFIDENTIAL