# FS_COMMAND_WRITEFILE

## Definition

  `FSResult FS_ARCHIVE_PROC_FUNC(FSFile *p_file, FSCommandType command /* = FS_COMMAND_WRITEFILE */);
  `

## Description

Operating specifications for the archive command `FS_COMMAND_WRITEFILE` are shown below:

Arguments passed to this command

>     This command takes as a command argument the variable arg.readfile that is stored in p_file.

>     This variable is defined in nitro/fs/file.h as shown below:

>     typedef struct
>     {
>         const void  *src;
>         u32     len_org;
>         u32     len;
>     } FSWriteFileInfo;

> Argument content is listed below:

Arguments | Content
src | The memory address for the source data to be written to a file.
len_org | Indicates the size of data to write (bytes), using the specified value as is.
len | Specifies the size of data to be written (bytes), using a value that is adjusted by the file size at the time that the command is called.

Actions required of this command

>     p_file is a handle that always holds file information in prop.file.

>     Based on p_file's prog.file variable, the command makes the following settings:

>     Transfers len bytes of data from memory indicated by src to an archive offset position that is indicated by prop.file.pos.
>       Adds value of len to prop.file.pos.

>       The value len is adjusted from the specified value, taking prop.file.bottom into consideration.
>       If you want to run a special process when a write exceeds the file size,
>       you can use the original value that is stored in len_org.

Default Implementation

> Uses the archive write callback function to transfer `len` bytes from `src` to the base offset position indicated by `prop.file.pos`. Adds value of `len` to `prop.file.pos`.

Command Results

>     If FS_RESULT_SUCCESS is returned by the command, it will be determined that the transfer process for len bytes completed properly.
>     When anything else is returned by the command, it will be determined that transfer failed due to some error.

Functions that use this command

> FS_WriteFile FS_WriteFileAsync

## See Also

`FSArchive`, `FS_ARCHIVE_PROC_FUNC`, `FS_COMMAND_*`, `FS_SetArchiveProc`

## Revision History

2004/07/12 Initial version.

CONFIDENTIAL