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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fat_open.c

?? ucfs的源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
**********************************************************************
*                          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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人黄色综合网站| 毛片不卡一区二区| a美女胸又www黄视频久久| 国产精品理伦片| 在线精品亚洲一区二区不卡| 亚洲一区二区在线免费观看视频 | 自拍偷拍国产精品| av成人免费在线观看| 一区二区三区在线视频观看| 欧美日韩一区二区三区四区五区| 日日摸夜夜添夜夜添精品视频 | 欧美精选午夜久久久乱码6080| 舔着乳尖日韩一区| 久久五月婷婷丁香社区| 99久久99久久精品免费看蜜桃| 亚洲综合一二三区| 日韩午夜三级在线| 成人黄色av电影| 亚洲午夜久久久| 久久久久久久久久久99999| eeuss鲁一区二区三区| 亚洲高清不卡在线| 久久九九影视网| 欧美日韩在线免费视频| 韩国欧美国产1区| 一区二区三区91| 精品久久久三级丝袜| 91在线视频免费观看| 日韩电影免费在线看| 中文在线资源观看网站视频免费不卡 | 亚洲国产aⅴ成人精品无吗| 欧美一个色资源| av不卡免费在线观看| 蜜臀av一区二区在线免费观看 | 日本道精品一区二区三区| 日韩电影免费一区| 亚洲三级在线播放| 久久综合av免费| 欧美视频完全免费看| 国产成人av电影| 日韩高清不卡一区| 亚洲黄色性网站| 久久精品日韩一区二区三区| 欧美午夜免费电影| www.欧美.com| 国产麻豆成人传媒免费观看| 亚洲一区二区欧美| 中文av一区特黄| 日韩精品一区二区三区三区免费 | 色综合av在线| 国产成人免费视频一区| 久久精品国产色蜜蜜麻豆| 一区二区三区在线免费视频| 国产欧美日韩一区二区三区在线观看| 欧美福利视频导航| 在线精品观看国产| 91亚洲精品乱码久久久久久蜜桃| 国产一区二区三区av电影| 日韩av电影一区| 亚洲成av人片观看| 夜夜爽夜夜爽精品视频| 国产精品久久久久久久午夜片| 精品国产免费一区二区三区四区 | 亚洲精品精品亚洲| 国产精品高潮呻吟| 国产喷白浆一区二区三区| 精品久久99ma| 日韩欧美久久久| 欧美高清视频在线高清观看mv色露露十八 | 日韩一区二区精品| 欧美精三区欧美精三区| 欧美精品亚洲二区| 9191久久久久久久久久久| 色综合亚洲欧洲| 在线精品视频免费观看| 精品视频一区 二区 三区| 欧美三级午夜理伦三级中视频| 色久综合一二码| 一本到一区二区三区| 91小视频在线| 欧美亚洲日本一区| 欧美日韩综合在线| 欧美一区二区三区在线| 日韩欧美国产高清| 久久影院视频免费| 久久九九影视网| 成人欧美一区二区三区1314| 亚洲人精品一区| 一区二区三区精品| 天堂成人国产精品一区| 婷婷亚洲久悠悠色悠在线播放| 午夜精品一区二区三区电影天堂| 日本不卡1234视频| 国产一区二区三区免费| 国产白丝精品91爽爽久久| 99re在线视频这里只有精品| 欧美性生活大片视频| 日韩欧美一二三四区| 中文字幕不卡在线播放| 亚洲午夜精品一区二区三区他趣| 日本一道高清亚洲日美韩| 国产精品一区久久久久| aaa亚洲精品| 3atv在线一区二区三区| www成人在线观看| 亚洲精品午夜久久久| 蜜臀国产一区二区三区在线播放| 国产不卡一区视频| 欧美日韩国产欧美日美国产精品| 欧美一区二区三区不卡| 中文字幕av免费专区久久| 亚洲成人777| 成人一区在线看| 欧美精品色综合| 亚洲欧洲色图综合| 日本强好片久久久久久aaa| 国产suv一区二区三区88区| 精品视频在线看| 欧美国产激情二区三区| 亚洲成人黄色小说| 国产成人三级在线观看| 欧美乱妇一区二区三区不卡视频| 久久精品人人做人人综合| 亚洲国产精品一区二区久久恐怖片 | 蜜臀a∨国产成人精品| av电影在线观看不卡| 精品日韩av一区二区| 亚洲精品免费一二三区| 国产一区二区三区免费观看| 欧美色爱综合网| 日韩理论片中文av| 国产一区欧美一区| 欧美日韩mp4| 亚洲欧美一区二区三区国产精品| 蜜桃av噜噜一区二区三区小说| 91在线你懂得| 国产日产欧美一区| 久久99国产精品尤物| 欧美在线一二三| 亚洲丝袜另类动漫二区| 国内精品免费在线观看| 欧美精品在线观看一区二区| 亚洲欧洲制服丝袜| 国产成人精品1024| 精品福利av导航| 日韩av一级片| 91麻豆精品国产91久久久| 亚洲精品va在线观看| 成人a区在线观看| 中文字幕av一区二区三区高| 国产资源在线一区| 日韩欧美国产系列| 日本视频中文字幕一区二区三区| 欧美在线免费观看亚洲| 亚洲激情图片一区| 99久久99久久久精品齐齐| 国产精品人妖ts系列视频| 国产一区二区在线视频| 26uuu久久综合| 国产在线播精品第三| 日韩精品一区二区三区四区 | 国产三级三级三级精品8ⅰ区| 免费人成精品欧美精品| 欧美蜜桃一区二区三区| 亚洲一区二区三区四区五区黄 | 国产日韩精品视频一区| 国产精品综合av一区二区国产馆| 日韩精品中午字幕| 韩国女主播成人在线| 久久久国产精品不卡| 国产露脸91国语对白| 国产三级精品三级在线专区| 懂色av中文一区二区三区| 国产精品久久毛片| 色婷婷国产精品| 亚洲一区二区免费视频| 欧美日韩国产小视频在线观看| 天堂成人国产精品一区| 日韩精品在线一区| 国产麻豆午夜三级精品| 国产精品久久久久婷婷二区次| 99国产精品一区| 午夜久久久久久电影| 日韩欧美激情四射| 粉嫩aⅴ一区二区三区四区| 亚洲三级电影网站| 欧美另类一区二区三区| 美女精品自拍一二三四| 欧美激情在线一区二区| 91论坛在线播放| 日韩二区三区四区| 国产视频一区不卡| 欧美亚洲国产怡红院影院| 美女www一区二区| 中文字幕精品三区| 欧美日韩国产另类不卡| 国产一区二区三区在线看麻豆| 国产精品美女久久福利网站| 日本二三区不卡| 国产在线观看一区二区|