_fs_fclose.c

来自「keil arm flash fs 最新版 在Keil arm下使用」· C语言 代码 · 共 46 行

C
46
字号
/*----------------------------------------------------------------------------
 *      R T L  -  F l a s h   F i l e   S y s t e m
 *----------------------------------------------------------------------------
 *      Name:    _FS_FCLOSE.C 
 *      Purpose: Low level File Close 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"

/*--------------------------- __fclose --------------------------------------*/

int __fclose (int handle) {
   /* Low level file close function. */
   FALLOC alloc;
   IOB *fcb;

   fcb = &_iob[handle];
   if (fcb->drive == DRV_MCARD) {
      /* Close a file opened on Flash Card. */
      if (fcb->flags & _IOWRT) {
         fat_close_write (fcb);
      }
      goto x;
   }
   if ((fcb->flags & _IOWRT) && (fcb->flags & _IOWALLOC)) {
      /* Write File Allocation Information to Flash */
      alloc.end    = fcb->_fbot;
      alloc.fileID = fcb->fileID;
      alloc.index  = fcb->_fidx;
      fs_WriteBlock (((DEVCONF *)fcb->DevCfg)[fcb->_fblock].bStart + fcb->_ftop,
                      &alloc, sizeof (FALLOC), fcb);
   }
x: fcb->fileID = 0;
   fcb->flags  = 0;
   return (0);
}

/*----------------------------------------------------------------------------
 * end of file
 *---------------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?