# FS_SetSeekCache

## Syntax

    #include <nitro/fs.h>

    BOOL FS_SetSeekCache(FSFile *file, void* buf, u32 bufsize);

## Arguments

`file` | An already open file. For more details, see the Notes section.
`buf` | Buffer to be used as the seek cache. Use of the cache buffer already configured is cancelled if NULL is specified. For details on the conditions that apply to the argument, see the Notes section.
bufsize | Buffer size. Use the `FS_GetSeekCacheSize` function to get the required size for the seek cache. If the size is small, the library will build the largest cache it can within the size provided.

## Return Values

Returns TRUE if the process succeeds.
Returns FALSE in the following situations.

- The specified buffer is not located in main memory
- The buffer region becomes 0 after the two ends of the specified buffer are cropped to a 32-byte cache line boundary

## Description

Sets the seek cache buffer.
With archives like NAND archives or SD Card archives that use FAT as the internal format, operations that seek to the end of the file and operations that seek in the reverse direction may require a significant execution cost. If you know that you will be making frequent use of seek operations on read-only files, you can improve the seek speed by using this function.

The buffer set with this function will be managed by the library until either the file is closed or NULL is specified to explicitly cancel use of the file.

This function uses only the cropped region of the specified buffer that remains after the start and end have been aligned with the cache line boundary. The buffer size retrieved by the `FS_GetSeekCacheSize` function contains enough space for addresses of any length.

## Note

- The file being specified must be opened in read-only mode.
- The seek cache being specified must be a buffer in main memory that is aligned to a boundary that is an integer multiple of 4 bytes.

## See Also

`FS_SeekFile
FS_GetSeekCacheSize`

## Revision History

2009/02/05 Explained the buffer's alignment to cache line boundary.
2008/07/01 Noted that the file must be opened in read-only mode.
2008/06/26 Initial version.

CONFIDENTIAL