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

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

?? fat_open.c

?? ucos在vc下的移植,并建立了文件系統
?? 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精品国产综合久久久久| 欧美天堂一区二区三区| 精品日韩欧美在线| 亚洲精品伦理在线| 国产成人综合网| 日韩女优电影在线观看| 亚洲午夜国产一区99re久久| 不卡一二三区首页| 国产日韩欧美在线一区| 精品中文字幕一区二区| 欧美日韩的一区二区| 亚洲欧美日韩中文字幕一区二区三区 | 亚洲一区二区三区精品在线| 国产精品一区在线观看乱码 | 欧美无砖砖区免费| 一色桃子久久精品亚洲| 成人午夜碰碰视频| 久久精品亚洲麻豆av一区二区 | 亚洲人成在线播放网站岛国| 成人午夜视频在线观看| 久久亚洲精品国产精品紫薇| 美女www一区二区| 日韩一区二区影院| 日韩和的一区二区| 91精品国产综合久久久久久久| 亚洲高清中文字幕| 欧美日韩亚洲不卡| 污片在线观看一区二区| 欧美性猛片aaaaaaa做受| 亚洲女厕所小便bbb| av一区二区三区黑人| 日本一区二区视频在线观看| 国产69精品一区二区亚洲孕妇| 久久久久青草大香线综合精品| 激情都市一区二区| 国产亚洲成aⅴ人片在线观看| 国产精品资源在线观看| 国产日韩v精品一区二区| 国产一区二区三区av电影| 久久久国产综合精品女国产盗摄| 国产一区日韩二区欧美三区| 欧美国产日韩a欧美在线观看| 成人在线综合网| 亚洲手机成人高清视频| 日本韩国欧美一区| 午夜精品福利一区二区三区av| 91麻豆精品91久久久久久清纯| 久99久精品视频免费观看| 久久久美女毛片| 色综合久久中文综合久久97| 亚洲一区二区三区三| 日韩美女一区二区三区四区| 国产乱码精品一区二区三区忘忧草 | 亚洲一区二区三区激情| 日韩视频一区在线观看| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 亚洲午夜电影网| 日韩久久久精品| 成人av在线网站| 亚洲成a人v欧美综合天堂| 久久综合九色综合97婷婷女人| 成人av电影在线| 日韩国产成人精品| 国产精品毛片久久久久久| 欧美区视频在线观看| 国产精品羞羞答答xxdd| 亚洲永久精品大片| 国产亚洲欧美在线| 欧美体内she精高潮| 国产在线精品一区二区不卡了| 亚洲麻豆国产自偷在线| 日韩欧美www| 91豆麻精品91久久久久久| 精品一区二区三区在线播放 | 国产在线一区二区| 一区二区三国产精华液| 久久精品一二三| 欧美一区午夜视频在线观看| www.欧美日韩国产在线| 免费欧美日韩国产三级电影| 亚洲欧洲av另类| 26uuu国产日韩综合| 欧美日韩中文国产| 91视频.com| 国产乱码精品1区2区3区| 日韩精品视频网| 亚洲精品国产a| 国产精品少妇自拍| 精品国产亚洲在线| 欧美一级片在线看| 欧美影片第一页| 91在线精品一区二区| 国产999精品久久久久久| 久久国产精品一区二区| 亚洲成精国产精品女| 一区二区三区精品在线| 日韩伦理电影网| 国产精品久久久久久久午夜片| 精品国产精品网麻豆系列| 欧美精品久久天天躁| 欧美午夜免费电影| 欧美色网一区二区| 在线观看三级视频欧美| 91免费看`日韩一区二区| 国产69精品久久久久777| 国产高清精品在线| 国产传媒日韩欧美成人| 韩国女主播一区| 国产在线国偷精品免费看| 国精产品一区一区三区mba桃花| 日本午夜一区二区| 久久国产欧美日韩精品| 久久99精品久久只有精品| 麻豆精品新av中文字幕| 九九久久精品视频| 国产成人精品网址| 成人午夜碰碰视频| 不卡的av电影在线观看| 91丨porny丨在线| 欧洲亚洲精品在线| 欧美日韩亚洲综合在线| 日韩午夜电影在线观看| 精品国产三级a在线观看| 久久久综合精品| 国产精品毛片a∨一区二区三区| 中文字幕一区二区三区在线不卡| 一区精品在线播放| 亚洲夂夂婷婷色拍ww47| 日本欧美一区二区在线观看| 国产在线精品视频| 成人av电影观看| 欧美日韩日日摸| 日韩女优制服丝袜电影| 日本一二三四高清不卡| 亚洲欧美国产高清| 免费观看一级欧美片| 丁香天五香天堂综合| 色噜噜夜夜夜综合网| 欧美日产在线观看| 久久久另类综合| 亚洲综合色噜噜狠狠| 免费观看在线色综合| 成人少妇影院yyyy| 欧美乱妇23p| 国产欧美一区二区精品婷婷| 亚洲欧美激情小说另类| 久久电影网电视剧免费观看| 成人一级黄色片| 欧美色图12p| 日本一区二区视频在线| 爽好久久久欧美精品| 成人在线综合网| 日韩一级完整毛片| 亚洲综合免费观看高清完整版| 国产一区二区在线观看免费| 91福利在线免费观看| 欧美激情中文不卡| 免费的成人av| 色狠狠av一区二区三区| 国产网站一区二区| 日日夜夜精品视频免费| 91免费观看在线| 国产欧美日本一区二区三区| 奇米一区二区三区av| 91福利视频久久久久| 中文字幕在线一区二区三区| 久久精品理论片| 欧美日韩国产精品成人| 亚洲欧美在线视频| 国产精品一区二区在线看| 3d成人h动漫网站入口| 亚洲精选视频免费看| 成人在线视频首页| 精品国产免费一区二区三区四区| 亚洲色图欧美激情| 久久国产生活片100| 欧美一区二区网站| 亚洲精品五月天| 国产一区二区三区高清播放| 日韩欧美电影一区| 一区二区三区在线播放| 午夜影院久久久| 91浏览器打开| 欧美国产乱子伦| 成人免费三级在线| 日韩欧美国产一二三区| 亚洲午夜久久久| 成人免费毛片aaaaa**| 欧美一二区视频| 五月激情六月综合| 丁香婷婷综合色啪| 国产精品久久久一区麻豆最新章节| 日韩中文字幕不卡| 欧美综合天天夜夜久久| 亚洲国产日韩精品| 色综合色狠狠综合色| 国产精品女上位| 91在线免费看| 1区2区3区欧美|