📄 fs_ffree.c
字号:
/*----------------------------------------------------------------------------
* R T L - F l a s h F i l e S y s t e m
*----------------------------------------------------------------------------
* Name: FS_FFREE.C
* Purpose: Get File System Free Space Function
* Rev.: V3.22
*----------------------------------------------------------------------------
* This code is part of the RealView Run-Time Library.
* Copyright (c) 2004-2008 KEIL - An ARM Company. All rights reserved.
*---------------------------------------------------------------------------*/
#include "File_Config.h"
/*--------------------------- ffree -----------------------------------------*/
U32 ffree (const char *drive) {
/* Find a free space in the Flash File System. */
IOB *fcb;
int handle;
U32 bl, free = 0;
/* Find an unused _iob structure. */
if ((handle = fs_find_iob ()) == EOF) {
return (0);
}
fcb = &_iob[handle];
/* Get the drive index. */
fcb->drive = fs_get_drive (drive);
if (fcb->drive == DRV_NONE && *drive == 0) {
/* Empty string provided for a drive name. */
fcb->drive = _DEF_DRIVE;
}
if (fcb->drive == DRV_NONE) {
/* Invalid drive letter specified. */
return (0);
}
if (fcb->drive == DRV_MCARD) {
/* Calculate Free Memory for a Flash Card. */
free = fat_free ();
return (free);
}
/* Set drive parameters. */
if (fs_set_params (fcb) == __FALSE) {
return (0);
}
for (bl = 0; bl < fcb->NumSect; bl++) {
/* Search all File Blocks for free space. */
free += fs_get_freeMem (bl, fcb);
}
return (free);
}
/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -