亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? fat_open.c

?? ucfs的源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號(hào):
/*
**********************************************************************
*                          Micrium, Inc.
*                      949 Crestview Circle
*                     Weston,  FL 33327-1848
*
*                            uC/FS
*
*             (c) Copyright 2001 - 2003, Micrium, Inc.
*                      All rights reserved.
*
***********************************************************************

----------------------------------------------------------------------
File        : fat_open.c
Purpose     : FAT routines for open/delete files
----------------------------------------------------------------------
Known problems or limitations with current version
----------------------------------------------------------------------
None.
---------------------------END-OF-HEADER------------------------------
*/

/*********************************************************************
*
*             #include Section
*
**********************************************************************
*/

#include "fs_conf.h"
#include "fs_port.h"
#ifndef FS_FARCHARPTR
#define FS_FARCHARPTR char *
#endif
#include "fs_dev.h"
#include "fs_api.h"
#include "fs_fsl.h"
#include "fs_int.h"
#include "fs_os.h"
#include "fs_lbl.h"
#include "fs_fat.h"
#include "fs_clib.h"


/*********************************************************************
*
*             #define constants
*
**********************************************************************
*/

#ifndef FS_FAT_NOFAT32
  #define FS_FAT_NOFAT32        0
#endif /* FS_FAT_NOFAT32 */


/*********************************************************************
*
*             Local functions
*
**********************************************************************
*/

/*********************************************************************
*
*             _FS_fat_find_file
*
  Description:
  FS internal function. Find the file with name pFileName in directory
  DirStart. Copy its directory entry to pDirEntry.
  
  Parameters:
  Idx         - Index of device in the device information table 
                referred by FS__pDevInfo.
  Unit        - Unit number.
  pFileName   - File name. 
  pDirEntry   - Pointer to an FS__fat_dentry_type data structure.
  DirStart    - 1st cluster of the directory.
  DirSize     - Sector (not cluster) size of the directory.
 
  Return value:
  >=0         - File found. Value is the first cluster of the file.
  <0          - An error has occured.
*/

static FS_i32 _FS_fat_find_file(int Idx, FS_u32 Unit, const char *pFileName,
                                    FS__fat_dentry_type *pDirEntry,
                                    FS_u32 DirStart, FS_u32 DirSize) {
  FS__fat_dentry_type *s;
  FS_u32 i;
  FS_u32 dsec;
  int len;
  int err; 
  int c;
  char *buffer;

  buffer = FS__fat_malloc(FS_FAT_SEC_SIZE);
  if (!buffer) {
    return -1;
  }
  len = FS__CLIB_strlen(pFileName);
  if (len > 11) {
    len = 11;
  }
  /* Read directory */
  for (i = 0; i < DirSize; i++) {
    dsec = FS__fat_dir_realsec(Idx, Unit, DirStart, i);
    if (dsec == 0) {
      FS__fat_free(buffer);
      return -1;
    }
    err = FS__lb_read(FS__pDevInfo[Idx].devdriver, Unit, dsec, (void*)buffer);
    if (err < 0) {
      FS__fat_free(buffer);
      return -1;
    }
    s = (FS__fat_dentry_type*)buffer;
    while (1) {
      if (s >= (FS__fat_dentry_type*)(buffer + FS_FAT_SEC_SIZE)) {
        break;  /* End of sector reached */
      }
      c = FS__CLIB_strncmp((char*)s->data, pFileName, len);
      if (c == 0) {  /* Name does match */
        if (s->data[11] & FS_FAT_ATTR_ARCHIVE) {
          break;  /* Entry found */
        }
      }
      s++;
    }
    if (s < (FS__fat_dentry_type*)(buffer + FS_FAT_SEC_SIZE)) {
      /* Entry found. Return number of 1st block of the file */
      if (pDirEntry) {
        FS__CLIB_memcpy(pDirEntry, s, sizeof(FS__fat_dentry_type));
      }
      FS__fat_free(buffer);
      dsec  = (FS_u32)s->data[26];
      dsec += (FS_u32)s->data[27] * 0x100UL;
      dsec += (FS_u32)s->data[20] * 0x10000UL;
      dsec += (FS_u32)s->data[21] * 0x1000000UL;
      return ((FS_i32)dsec);
    }
  }
  FS__fat_free(buffer);
  return -1;
}


/*********************************************************************
*
*             _FS_fat_IncDir
*
  Description:
  FS internal function. Increase directory starting at DirStart.
  
  Parameters:
  Idx         - Index of device in the device information table 
                referred by FS__pDevInfo.
  Unit        - Unit number.
  DirStart    - 1st cluster of the directory.
  pDirSize    - Pointer to an FS_u32, which is used to return the new 
                sector (not cluster) size of the directory.
 
  Return value:
  ==1         - Success.
  ==-1        - An error has occured.
*/

static int _FS_fat_IncDir(int Idx, FS_u32 Unit, FS_u32 DirStart, FS_u32 *pDirSize) {
  FS_u32 i;
  FS_u32 dsec;
  FS_i32 last;
  char *buffer;
  int err;

  if (DirStart == 0) { 
    /* Increase root directory only, if not FAT12/16  */
    i = FS__FAT_aBPBUnit[Idx][Unit].RootEntCnt;
    if (i != 0) {
      return -1;  /* Not FAT32 */
    }
  }
  last = FS__fat_FAT_find_eof(Idx, Unit, DirStart, 0);
  if (last < 0) {
    return -1;  /* No EOF marker found */
  }
  last = FS__fat_FAT_alloc(Idx, Unit, last);  /* Allocate new cluster */
  if (last < 0) {
    return -1;
  }
  *pDirSize = *pDirSize + FS__FAT_aBPBUnit[Idx][Unit].SecPerClus;
  /* Clean new directory cluster */
  buffer = FS__fat_malloc(FS_FAT_SEC_SIZE);
  if (!buffer) {
    return -1;
  }
  FS__CLIB_memset(buffer, 0x00, (FS_size_t)FS_FAT_SEC_SIZE);
  for (i = *pDirSize - FS__FAT_aBPBUnit[Idx][Unit].SecPerClus; i < *pDirSize; i++) {
    dsec = FS__fat_dir_realsec(Idx, Unit, DirStart, i);
    if (dsec == 0) {
      FS__fat_free(buffer);
      return -1;
    }
    err = FS__lb_write(FS__pDevInfo[Idx].devdriver, Unit, dsec, (void*)buffer);
    if (err < 0) {
      FS__fat_free(buffer);
      return -1;
    }
  }
  FS__fat_free(buffer);
  return 1;
}


/*********************************************************************
*
*             _FS_fat_create_file
*
  Description:
  FS internal function. Create a file in the directory specified
  with DirStart. Do not call, if you have not checked before for 
  existing file with name pFileName.

  Parameters:
  Idx         - Index of device in the device information table 
                referred by FS__pDevInfo.
  Unit        - Unit number, which is passed to the device driver.
  pFileName   - File name. 
  DirStart    - Start of directory, where to create pDirName.
  DirSize     - Sector size of the directory starting at DirStart.
  
  Return value:
  >=0         - 1st cluster of the new file.
  ==-1        - An error has occured.
  ==-2        - Cannot create, because directory is full.
*/

static FS_i32 _FS_fat_create_file(int Idx, FS_u32 Unit,  const char *pFileName,
                                    FS_u32 DirStart, FS_u32 DirSize) {
  FS__fat_dentry_type *s;
  FS_u32 i;
  FS_u32 dsec;
  FS_i32 cluster;
  int len;
  int err;
  FS_u16 val;
  char *buffer;

  buffer = FS__fat_malloc(FS_FAT_SEC_SIZE);
  if (!buffer) {
    return -1;
  }
  len = FS__CLIB_strlen(pFileName);
  if (len > 11) {
    len = 11;
  }
  /* Read directory */
  for (i = 0; i < DirSize; i++) {
    dsec = FS__fat_dir_realsec(Idx, Unit, DirStart, i);
    if (dsec == 0) {
      FS__fat_free(buffer);
      return -1;
    }
    err = FS__lb_read(FS__pDevInfo[Idx].devdriver, Unit, dsec, (void*)buffer);
    if (err < 0) {
      FS__fat_free(buffer);
      return -1;
    }
    s = (FS__fat_dentry_type*)buffer;
    while (1) {
      if (s >= (FS__fat_dentry_type*)(buffer + FS_FAT_SEC_SIZE)) {
        break;  /* End of sector reached */
      }
      if (s->data[0] == 0x00) {
        break;  /* Empty entry found */
      }
      if (s->data[0] == (unsigned char)0xe5) {
        break;  /* Deleted entry found */
      }
      s++;
    }
    if (s < (FS__fat_dentry_type*)(buffer + FS_FAT_SEC_SIZE)) {
      /* Free entry found. Make entry and return 1st block of the file */
      FS__CLIB_strncpy((char*)s->data, pFileName, len);
      s->data[11] = FS_FAT_ATTR_ARCHIVE;
      /* Alloc block in FAT */
      cluster = FS__fat_FAT_alloc(Idx, Unit, -1);
      if (cluster >= 0) {
        s->data[12]     = 0x00;                           /* Res */
        s->data[13]     = 0x00;                           /* CrtTimeTenth (optional, not supported) */
        s->data[14]     = 0x00;                           /* CrtTime (optional, not supported) */
        s->data[15]     = 0x00;
        s->data[16]     = 0x00;                           /* CrtDate (optional, not supported) */
        s->data[17]     = 0x00;
        s->data[18]     = 0x00;                           /* LstAccDate (optional, not supported) */
        s->data[19]     = 0x00;
        val             = FS_X_OS_GetTime();
        s->data[22]     = (unsigned char)(val & 0xff);   /* WrtTime */
        s->data[23]     = (unsigned char)(val / 256);
        val             = FS_X_OS_GetDate();
        s->data[24]     = (unsigned char)(val & 0xff);   /* WrtDate */
        s->data[25]     = (unsigned char)(val / 256);
        s->data[26]     = (unsigned char)(cluster & 0xff);    /* FstClusLo / FstClusHi */ 
        s->data[27]     = (unsigned char)((cluster / 256) & 0xff);
        s->data[20]     = (unsigned char)((cluster / 0x10000L) & 0xff);
        s->data[21]     = (unsigned char)((cluster / 0x1000000L) & 0xff);
        s->data[28]     = 0x00;                           /* FileSize */
        s->data[29]     = 0x00;
        s->data[30]     = 0x00;
        s->data[31]     = 0x00;
        err = FS__lb_write(FS__pDevInfo[Idx].devdriver, Unit, dsec, (void*)buffer);
        if (err < 0) {
          FS__fat_free(buffer);
          return -1;
        }
      }
      FS__fat_free(buffer);
      return cluster;
    }
  }
  FS__fat_free(buffer);
  return -2;      /* Directory is full */
}


/*********************************************************************
*
*             Global functions section 1
*
**********************************************************************

  Functions in this section are global, but are used inside the FAT
  File System Layer only.
  
*/

/*********************************************************************
*
*             FS__fat_DeleteFileOrDir
*
  Description:
  FS internal function. Delete a file or directory.
  
  Parameters:
  Idx         - Index of device in the device information table 
                referred by FS__pDevInfo.
  Unit        - Unit number, which is passed to the device driver.
  pName       - File or directory name. 
  DirStart    - Start of directory, where to create pDirName.
  DirSize     - Sector size of the directory starting at DirStart.
  RmFile      - 1 => remove a file
                0 => remove a directory
  
  Return value:
  >=0         - Success. 
  <0          - An error has occured.
*/

FS_i32 FS__fat_DeleteFileOrDir(int Idx, FS_u32 Unit,  const char *pName,
                                    FS_u32 DirStart, FS_u32 DirSize, char RmFile) {
  FS__fat_dentry_type *s;
  FS_u32 dsec;
  FS_u32 i;
  FS_u32 value;
  FS_u32 fatsize;
  FS_u32 filesize;
  FS_i32 len;
  FS_i32 bytespersec;
  FS_i32 fatindex;
  FS_i32 fatsec;
  FS_i32 fatoffs;
  FS_i32 lastsec;
  FS_i32 curclst;
  FS_i32 todo;
  char *buffer;
  int fattype;
  int err;
  int err2;
  int lexp;
  int x;
  unsigned char a;
  unsigned char b;
#if (FS_FAT_NOFAT32==0)
  unsigned char c;
  unsigned char d;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本韩国欧美在线| 午夜精品视频在线观看| 日韩va欧美va亚洲va久久| 成人动漫av在线| 精品久久国产字幕高潮| 亚洲狠狠丁香婷婷综合久久久| 国产在线一区二区综合免费视频| 欧美日韩一区视频| 国产精品视频你懂的| 六月丁香婷婷久久| 欧美性感一类影片在线播放| 国产情人综合久久777777| 免费一级欧美片在线观看| 色八戒一区二区三区| 国产日韩欧美亚洲| 麻豆精品国产传媒mv男同| 在线免费观看一区| 亚洲少妇中出一区| caoporn国产精品| 国产欧美一区二区在线观看| 国产制服丝袜一区| 欧美不卡一区二区三区四区| 首页亚洲欧美制服丝腿| 色网综合在线观看| 国产精品的网站| 国产精品一二三四| 久久一二三国产| 麻豆精品在线播放| 4hu四虎永久在线影院成人| 亚洲伊人伊色伊影伊综合网| 99re这里都是精品| 亚洲国产精品高清| 国产精品123区| 精品国产乱码久久久久久久久| 日本不卡不码高清免费观看| 欧美高清视频一二三区 | 日本久久精品电影| 亚洲男女一区二区三区| 99免费精品视频| 国产精品日产欧美久久久久| 国产一区二区三区视频在线播放| 精品福利在线导航| 韩国三级中文字幕hd久久精品| 日韩欧美在线影院| 精品一区二区在线视频| 欧美va亚洲va| 国产在线精品免费| 欧美国产国产综合| www.爱久久.com| 亚洲欧美日韩国产成人精品影院| 色悠久久久久综合欧美99| 亚洲综合小说图片| 欧美精品tushy高清| 日本麻豆一区二区三区视频| 欧美电影免费观看高清完整版在线| 蜜桃视频一区二区三区| wwwwxxxxx欧美| 国产福利91精品| 国产精品欧美一级免费| 欧美国产综合一区二区| 风间由美中文字幕在线看视频国产欧美| 欧美韩日一区二区三区| 波多野结衣在线一区| 亚洲欧美日韩久久| 欧美三级蜜桃2在线观看| 日韩精品电影在线观看| 亚洲精品在线观看网站| 成人在线视频一区二区| 亚洲日本成人在线观看| 欧美日韩一区三区| 经典三级一区二区| 国产精品美女久久久久久| 91网站在线观看视频| 亚洲超碰97人人做人人爱| 日韩一区二区视频| 国产成人在线视频播放| 综合电影一区二区三区| 欧美视频日韩视频| 精品一区二区三区免费| 日本一区二区三区国色天香| 91高清视频免费看| 久久99久久久欧美国产| 国产精品美女视频| 丁香网亚洲国际| 国产福利一区二区三区视频在线| 亚洲永久精品大片| 五月综合激情网| 成人18精品视频| 欧美视频你懂的| 欧美一级高清片| 日韩一区二区三区四区五区六区| 中文字幕精品一区二区精品绿巨人 | 麻豆专区一区二区三区四区五区| 麻豆一区二区三区| 国产伦精品一区二区三区免费迷 | 欧美精品丝袜久久久中文字幕| 日本强好片久久久久久aaa| 精品国精品自拍自在线| 99国产麻豆精品| 日韩成人av影视| 中文字幕一区二区三区在线播放 | 麻豆一区二区在线| 自拍偷在线精品自拍偷无码专区| 欧美一级艳片视频免费观看| 粉嫩高潮美女一区二区三区| 午夜精品久久久久久久久久久| 国产午夜精品在线观看| 欧美日韩激情一区二区| 粉嫩av一区二区三区在线播放 | 亚洲女厕所小便bbb| 欧美videossexotv100| 在线亚洲一区观看| 99久久99久久精品免费观看| 欧美精品色综合| 日韩精品高清不卡| 99久久精品99国产精品 | 美女在线视频一区| 亚洲色图都市小说| 久久婷婷久久一区二区三区| 欧美亚洲一区三区| eeuss鲁片一区二区三区在线看| 久久黄色级2电影| 亚洲综合激情网| 国产精品美日韩| 2022国产精品视频| 欧美一区二区免费观在线| 色噜噜偷拍精品综合在线| 国v精品久久久网| 国产一区美女在线| 日本免费新一区视频 | 久久综合色8888| 欧美日本国产一区| 91论坛在线播放| 成人动漫一区二区在线| 精品亚洲aⅴ乱码一区二区三区| 亚洲成人激情av| 国产精品久久久久久久午夜片| 日韩欧美国产不卡| 欧美精品在线观看播放| 在线观看av不卡| 色女孩综合影院| av不卡免费在线观看| 懂色av一区二区三区蜜臀| 久久97超碰国产精品超碰| 青娱乐精品在线视频| 日韩高清中文字幕一区| 天使萌一区二区三区免费观看| 亚洲主播在线播放| 亚洲影院免费观看| 亚洲高清免费观看| 亚洲成人在线免费| 一区二区三区高清在线| 91官网在线观看| 欧美高清www午色夜在线视频| 亚洲电影你懂得| 国产精品一区在线观看乱码| 日韩国产高清影视| 日本伊人色综合网| 日本在线不卡视频| 日韩不卡手机在线v区| 丝袜a∨在线一区二区三区不卡| 亚洲韩国精品一区| 午夜精品久久久久久不卡8050| 亚洲国产成人av好男人在线观看| 亚洲电影中文字幕在线观看| 亚洲a一区二区| 日本三级亚洲精品| 国产一区二区网址| 成人sese在线| 在线影视一区二区三区| 欧美人牲a欧美精品| 欧美高清激情brazzers| 欧美大黄免费观看| 国产视频在线观看一区二区三区| 国产欧美精品一区二区色综合 | 日韩免费福利电影在线观看| 精品美女一区二区三区| 久久久综合视频| 中文字幕欧美日韩一区| 亚洲视频香蕉人妖| 午夜私人影院久久久久| 久久99精品一区二区三区 | 亚洲国产综合91精品麻豆| 日韩在线一区二区| 国精产品一区一区三区mba视频 | 午夜视频一区在线观看| 青青草成人在线观看| 国产主播一区二区| 99久久国产综合色|国产精品| 在线看国产一区二区| 4438成人网| 2022国产精品视频| 亚洲精品日韩综合观看成人91| 一区二区三区欧美视频| 奇米精品一区二区三区在线观看| 国产大陆亚洲精品国产| 欧美性三三影院| 久久蜜臀精品av| 亚洲国产欧美日韩另类综合| 免费人成精品欧美精品|