下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

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

ff_truncate() [FreeRTOS-Plus-FAT 标准 API 引用]

ff_stdio.h
FF_FILE *ff_truncate( const char * pcFileName, long lTruncateSize );
  打开文件进行写入,然后将文件的长度截断为 lTruncateSize。 如果文件长于 lTruncateSize,则超过 lTruncateSize 的数据 将被丢弃。 如果文件比 lTruncateSize 短,则添加到文件末尾的新数据 将被设置为 0。 参数:
pcFileName 指向以 null 结尾的标准 C 字符串的指针,该字符串包含 正在打开和截断的文件的名称。文件名可以 包括所述文件的相对路径。
lTruncateSize 文件长度将设置的字节长度 。
返回: 如果文件长度已成功设置为 lTruncateSize,则 返回指向打开文件的指针。 如果文件长度未成功设置为 lTruncateSize,则 返回 NULL,文件将保持关闭状态,并且任务 并设置任务的 errno 以指示原因。任务 可以使用 stdioGET_ERRNO() API 函数 获取其 errno 值。 用法示例:

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

/* Open and truncate the file specified by the pcFileName parameter. */
pxFile = ff_truncate( pcFileName, lLength );

if( pxFile == NULL )
{
/* The file could not be opened, or the file could not be truncated. */
}
else
{
/* The file was opened and the file length was set. */

/*
* The file can be accessed here.
*/


/* Close the file when it is no longer required. */
ff_fclose( pxFile );
}
}

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