FS_ReadFile

Syntax


#include <nitro/fs.h>
s32 FS_ReadFile( FSFile *p_file, void *dst, s32 len);

Arguments

file FSFile structure that indicates an opened file.
dst Destination buffer
len Length of data being read, in bytes.

Return Values

If the data is correctly read, it returns the number of bytes. Otherwise it returns a value of -1.

Description

This function reads a specified size of data from the file pointer's current position. If the specified amount of data would extend beyond the end of the file, the function reads to the end of the file and returns the number of bytes to that point.

If you are using the ROM archive to read Game Card data, also see the description for the CARD_ReadRomAsync function.

The read process executed by this function differs depending on which archive has been implemented. In some cases, DMA, ARM7, or other external memory devices may be used. The FS library guarantees the consistency of CPU cache and real memory before and after the call to this function. If the application inadvertently references the contents of the read buffer before this function has completed its read process, the consistency of CPU cache and real memory will be lost. For this reason, the buffer passed to this function should not be referenced until processing is complete.

Note

See Also

FS_CloseFile
FSFile
FS_GetFileLength
FS_OpenFileEx
FS_OpenFileFast
FS_SeekFile
FS_SeekFileToBegin
FS_SeekFileToEnd

Revision History

2008/12/05 Noted that the buffer should not be referenced during processing.
2008/10/02 Updated part of the See Also list.
2008/02/27 Added mention that the cache synchronicity of the read data is not guaranteed.
2005/08/28 Added links to CARD_ReadRomAsync function in description.
2004/09/24 Added text under Caution regarding the conditions for calling and completing this function.
2004/04/01 Initial version.


CONFIDENTIAL