下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

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

ff_ftell()

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

ff_stdio.h
long ff_ftell( FF_FILE *pxStream );
		

返回嵌入式 FAT 文件系统中打开的文件的当前读/写位置。 位置返回为从文件开头算起的字节数。

参数:

pxStream   正在查询的文件。 必须首先通过 调用 ff_fopen() 来打开该文件。
返回:

如果 pxStream 不为 NULL,则文件的当前读/写 位置已被返回。 返回值为 文件读/写位置从文件开头算起的字节数。

如果 pxStream 为 NULL,则返回 -1。

用法示例:


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

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

/* Expect the file position to be 0. */
lPosition = ff_ftell( pxFile );
configASSERT( lPosition == 0 );

/* Read one byte. */
ff_fread( pcBuffer, 1, 1, pxFile );

/* Expect the file position to be 1. */
lPosition = ff_ftell( pxFile );
configASSERT( lPosition == 1 );

/* Read another byte. */
ff_fread( pcBuffer, 1, 1, pxFile );

/* Expect the file position to be 2. */
lPosition = ff_ftell( pxFile );
configASSERT( lPosition == 2 );

/* Close the file again. */
ff_fclose( pxFile );
}

Example use of the ff_ftell() API function


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.