下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

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

ff_feof()

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

ff_stdio.h
int ff_feof( FF_FILE *pxStream );
		

在嵌入式 FAT 文件系统中查询打开的文件,以查看文件的 读取/写入指针是否位于文件末尾。

参数:

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

如果文件的读取/写入指针位于文件末尾, 则返回非零值。

如果文件的读取/写入指针不在文件末尾,并且没有 发生错误,则返回 0,并且任务的 errno 也设置为 0。

如果错误阻止了函数确定文件的 读取/写入指针的位置,则返回零,并且任务的 errno 设置为指示原因。

任务可以使用 stdioGET_errno API 函数 获取其 errno 值。

用法示例:


void vSampleFunction( char *pcFileName, char *pcBuffer, int32_t lBufferSize )
{
FF_FILE *pxFile;
int32_t lBytesRead;
int iReturnedByte;

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

/* Read the number of bytes specified by the lBufferSize parameter. */
for( lBytesRead = 0; lBytesRead < lBufferSize; lBytesRead++ )
{
if( ff_feof( pxFile ) != 0 )
{
/* The end of the file has been reached, there are no more bytes to
read. */

break;
}
else
{
iReturnedByte = ff_fgetc( pxFile );
}

/* Write the byte into the buffer. */
pcBuffer[ lBytesRead ] = ( char ) iReturnedByte;
}

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

Example use of the ff_feof() API function


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