下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

最新资讯
简化任何设备的身份验证云连接。
利用 CoAP 设计节能型云连接 IoT 解决方案。
11.0.0 版 FreeRTOS 内核简介:
FreeRTOS 路线图和代码贡献流程。
使用 FreeRTOS 实现 OPC-UA over TSN。

ff_fseek()

[FreeRTOS-Plus-FAT 标准 API 引用]

ff_stdio.h
int ff_fseek( FF_FILE *pxStream, int iOffset, int iWhence );
		

将打开文件的当前读/写位置移动到 ( iWhence + iOffset )。

参数:

pxStream   正在更新当前读/写位置的 文件。

iOffset   与 iWhence 参数设置的位置(将设置的文件当前读/写位置) 的偏移量 (以字节为单位)。

iWhence   文件中 iOffset 值的 相对位置。 iWhence 的有效值包括:

说明
FF_SEEK_CUR 当前文件位置。
FF_SEEK_END 文件结尾。
FF_SEEK_SET 文件开头。

返回:

成功时返回 0。

如果无法移动读/写位置,则返回 -1, errno 以指示原因。 任务 可以使用 stdioGET_ERRNO() API 函数 获取其 errno 值。

用法示例:


void vSampleFunction( char *pcFileName, char *pcBuffer )
{
FF_FILE *pxFile;

/* Open the file specified by the pcFileName parameter. */
pxFile = ff_fopen( pcFileName, "r" );

if( pxFile != NULL )
{
/* Read one byte from the opened file. */
ff_fread( pcBuffer, 1, 1, pxFile );

/* Move the current file position back to the very start of the file. */
ff_fseek( pxFile, 0, FF_SEEK_SET );

/* Read a byte again. As the file position was moved back to the start
of the file the byte that is read is the same byte read by the first
ff_fread() call. */

ff_fread( pcBuffer, 1, 1, pxFile );

/* This time move the current position to the last byte in the file. */
ff_fseek( pxFile, -1, FF_SEEK_END );

/* Now the byte read is the last byte in the file. */
ff_fread( pcBuffer, 1, 1, pxFile );

/* Finished with the file, close it. */
ff_fclose( pxFile );
}
}

Example use of the ff_fseek() API function
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.