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

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

?? fat_open.c

?? 基于Vc的UCFS程序,作者在電腦上開辟了一段RAM來作為文件系統存儲. 對學習fat文件系統很有幫助.
?? 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一区二区三区免费野_久草精品视频
久久久午夜精品理论片中文字幕| 亚洲午夜日本在线观看| 精品国精品自拍自在线| 91精品国产综合久久蜜臀| 欧美精品在线一区二区三区| 精品视频在线免费观看| 欧美在线观看一区二区| 欧美专区日韩专区| 欧美日韩一区三区四区| 欧美伦理影视网| 欧美一区日韩一区| 欧美成人免费网站| 久久久精品人体av艺术| 欧美国产在线观看| 亚洲色图.com| 亚洲一区二区三区小说| 日韩和欧美一区二区| 免费观看在线色综合| 国产一区二区日韩精品| 成人性生交大片| 91麻豆6部合集magnet| 欧美三级韩国三级日本一级| 欧美日韩精品是欧美日韩精品| 91.麻豆视频| 久久老女人爱爱| 国产精品国产三级国产三级人妇| 伊人夜夜躁av伊人久久| 日韩和欧美一区二区三区| 韩国毛片一区二区三区| eeuss鲁片一区二区三区在线观看| 波多野结衣的一区二区三区| 色综合天天综合网国产成人综合天 | 在线电影一区二区三区| 日韩视频在线你懂得| 久久久噜噜噜久久人人看| 国产精品久久久99| 视频一区视频二区中文字幕| 狠狠色狠狠色综合日日91app| 国产iv一区二区三区| 91成人在线免费观看| 91精品国产一区二区三区蜜臀| 久久老女人爱爱| 亚洲综合色成人| 国产在线看一区| 一本色道久久综合亚洲91| 欧美一区二区三区在线电影| 国产女主播视频一区二区| 一级精品视频在线观看宜春院| 日本成人在线看| 暴力调教一区二区三区| 欧美一卡二卡在线| 中文字幕亚洲一区二区av在线| 婷婷亚洲久悠悠色悠在线播放| 国产精品99久久久久久有的能看| 色综合久久天天综合网| 精品国产a毛片| 亚洲制服丝袜av| 国产91丝袜在线播放| 在线播放欧美女士性生活| 国产精品美女久久久久av爽李琼| 天堂在线亚洲视频| 91视频一区二区三区| 欧美成人精品1314www| 亚洲另类中文字| 国产成人综合在线| 91精品婷婷国产综合久久| 中文字幕日本不卡| 国内精品国产成人国产三级粉色| 欧美性生活影院| 中文字幕不卡一区| 久久国产综合精品| 欧美日韩国产精品成人| 国产精品国产三级国产普通话蜜臀| 欧美aaa在线| 欧美三级电影在线观看| 国产精品九色蝌蚪自拍| 国产剧情av麻豆香蕉精品| 欧美肥大bbwbbw高潮| 亚洲男人的天堂网| 不卡的av电影在线观看| 欧美精品一区二区三区久久久| 亚洲成人av在线电影| 91蜜桃传媒精品久久久一区二区| 久久精品亚洲国产奇米99| 麻豆一区二区99久久久久| 欧美日韩一区不卡| 亚洲免费观看高清完整| www.激情成人| 亚洲国产精品黑人久久久| 韩国三级中文字幕hd久久精品| 555www色欧美视频| 亚洲444eee在线观看| 在线国产电影不卡| 亚洲理论在线观看| 色屁屁一区二区| 亚洲人吸女人奶水| 色综合久久久久综合99| 亚洲色图制服丝袜| 97se亚洲国产综合自在线| 国产精品色呦呦| 成人动漫在线一区| 国产精品福利一区二区三区| 成人av片在线观看| 最新国产成人在线观看| 99精品视频免费在线观看| 中文字幕日韩一区| 97精品国产97久久久久久久久久久久| 国产精品天干天干在线综合| 成人av网站在线观看免费| 国产精品天天看| 91免费国产在线| 亚洲综合一区二区| 777xxx欧美| 精品中文字幕一区二区| 久久久久久久av麻豆果冻| 国产福利一区在线观看| 国产精品萝li| 一本色道久久综合精品竹菊| 亚洲国产成人va在线观看天堂| 欧美日韩和欧美的一区二区| 日韩激情一二三区| 欧美精品一区二区三区在线| 岛国精品一区二区| 亚洲丝袜美腿综合| 欧美午夜精品电影| 久久精品国产精品亚洲综合| 久久亚洲综合色| av中文字幕在线不卡| 亚洲一区二区在线观看视频| 欧美日韩精品二区第二页| 麻豆精品在线视频| 中文欧美字幕免费| 欧美中文字幕一二三区视频| 七七婷婷婷婷精品国产| 国产亲近乱来精品视频| 色偷偷久久人人79超碰人人澡 | 97精品久久久午夜一区二区三区| 一区二区欧美精品| 欧美成人video| 风间由美一区二区三区在线观看 | 蜜臀av一区二区在线免费观看| 亚洲精品一区二区三区福利| 成人黄色国产精品网站大全在线免费观看 | 欧美亚洲图片小说| 久久精品久久99精品久久| 日本一区二区三级电影在线观看| 色哟哟在线观看一区二区三区| 丝袜美腿亚洲一区二区图片| 久久伊人中文字幕| 日本高清免费不卡视频| 欧美aⅴ一区二区三区视频| 国产亚洲精品中文字幕| 日本高清不卡aⅴ免费网站| 欧美aⅴ一区二区三区视频| 国产精品毛片高清在线完整版| 欧美色大人视频| 国产麻豆精品在线观看| 亚洲理论在线观看| 精品入口麻豆88视频| 91美女福利视频| 精品制服美女久久| 一二三区精品视频| 26uuuu精品一区二区| 欧美午夜一区二区三区| 国产91精品露脸国语对白| 天天色天天操综合| 国产精品第13页| 日韩女优毛片在线| 欧美在线观看视频一区二区三区| 精品一二线国产| 亚洲一级不卡视频| 国产精品美女久久久久aⅴ | 国产精品乱人伦| 欧美一级日韩不卡播放免费| 91免费看视频| 国产高清精品网站| 久久99热这里只有精品| 夜色激情一区二区| 中文字幕成人av| 精品日韩在线观看| 666欧美在线视频| 色婷婷一区二区三区四区| 国产露脸91国语对白| 裸体歌舞表演一区二区| 亚洲h动漫在线| 一区二区三区在线视频免费 | 五月天激情综合| 亚洲欧美日韩小说| 中文字幕在线一区| 国产亚洲综合色| 精品国产在天天线2019| 91精品国产乱码| 欧美日韩国产a| 欧美在线你懂的| 色88888久久久久久影院野外| av午夜一区麻豆| 成人毛片老司机大片| 国产成人亚洲综合a∨猫咪| 狠狠狠色丁香婷婷综合激情 | 777奇米成人网|