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

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

?? fat_open.c

?? 這套代碼已經成功一直到S3C44B0X開發板上
?? 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美女片黄在线观看91美女| 国产精品久久二区二区| 在线视频亚洲一区| 91精品1区2区| 91国偷自产一区二区三区成为亚洲经典| 高清国产一区二区| 国产福利91精品| 成人高清视频在线观看| av中文一区二区三区| 91丨九色丨蝌蚪丨老版| 色丁香久综合在线久综合在线观看| 一本久久综合亚洲鲁鲁五月天 | 久久久影视传媒| 久久久国产精品麻豆| 国产片一区二区| 国产精品丝袜黑色高跟| 17c精品麻豆一区二区免费| 亚洲色图第一区| 午夜欧美一区二区三区在线播放| 日韩精品欧美成人高清一区二区| 免费日韩伦理电影| 国模无码大尺度一区二区三区| 国产精品自拍三区| 国产91精品一区二区| 91亚洲男人天堂| 欧美三级乱人伦电影| 欧美一级日韩不卡播放免费| 精品人在线二区三区| 国产精品三级av| 一区二区三区精品| 日本不卡在线视频| 国产精品一区二区不卡| 久久综合久色欧美综合狠狠| 欧美国产精品一区| 亚洲综合一区二区三区| 蜜臀av亚洲一区中文字幕| 国产大片一区二区| 色综合天天性综合| 欧美一级淫片007| 中文字幕在线观看一区| 日韩精品国产精品| 国产中文一区二区三区| 色综合久久精品| 日韩一区二区三区四区| 国产精品福利一区| 丝袜国产日韩另类美女| 国产成a人亚洲| 欧美日韩mp4| 欧美激情一二三区| 视频精品一区二区| 成熟亚洲日本毛茸茸凸凹| 666欧美在线视频| 欧美国产精品一区二区| 日韩精品久久久久久| 不卡视频一二三四| 制服丝袜中文字幕亚洲| 国产精品伦理在线| 日韩高清中文字幕一区| 成人动漫视频在线| 日韩免费视频一区二区| 一区二区三区丝袜| 国产黄色成人av| 91精品国产福利| 亚洲美女淫视频| 国产精品一区二区黑丝| 欧美另类高清zo欧美| 日韩一区在线播放| 免费成人在线影院| 欧美三级一区二区| 亚洲男同性恋视频| 国产精品 欧美精品| 91麻豆精品国产91久久久久久久久| 国产人成亚洲第一网站在线播放| 日本亚洲三级在线| 欧美亚洲一区二区三区四区| 国产日韩欧美a| 美女在线一区二区| 欧美图区在线视频| 成人免费一区二区三区视频| 国v精品久久久网| 精品国产sm最大网站| 日日摸夜夜添夜夜添国产精品| 97国产一区二区| 国产三级欧美三级| 久久精品国产亚洲5555| 555夜色666亚洲国产免| 亚洲国产一二三| 色一情一乱一乱一91av| 国产精品久久久久四虎| 粉嫩av一区二区三区在线播放| 日韩欧美一级在线播放| 丝袜亚洲另类丝袜在线| 欧美日韩视频专区在线播放| 有坂深雪av一区二区精品| 99久久国产综合精品色伊| 国产一区二区伦理片| 日韩午夜在线观看视频| 人人精品人人爱| 91精品国产一区二区人妖| 图片区小说区区亚洲影院| 精品视频一区二区三区免费| 亚洲激情图片qvod| 色综合久久久网| 一区二区三区中文字幕电影 | 欧美精品一区二| 韩国精品主播一区二区在线观看| 日韩精品一区二区三区视频| 日本成人中文字幕在线视频| 91精品国产高清一区二区三区 | 男人的天堂亚洲一区| 在线不卡中文字幕| 美女视频网站久久| 精品国产乱码久久久久久免费| 国产在线视频一区二区三区| 久久久精品免费网站| 成人看片黄a免费看在线| 亚洲私人影院在线观看| 91麻豆免费观看| 艳妇臀荡乳欲伦亚洲一区| 欧美日韩国产小视频| 美女任你摸久久 | 亚洲bt欧美bt精品777| 欧美精品xxxxbbbb| 精品一区在线看| 久久九九久久九九| av在线不卡网| 亚洲综合无码一区二区| 91精品国产一区二区三区| 激情成人午夜视频| 国产精品亲子乱子伦xxxx裸| 91蜜桃免费观看视频| 亚洲v日本v欧美v久久精品| 日韩一区二区电影在线| 久久―日本道色综合久久| 国产黄色精品视频| 亚洲免费高清视频在线| 欧美精品丝袜中出| 国产酒店精品激情| 亚洲乱码精品一二三四区日韩在线| 欧美色综合天天久久综合精品| 日韩福利视频导航| 欧美国产一区在线| 欧亚一区二区三区| 精品综合免费视频观看| 国产精品美女一区二区三区 | 欧美日韩在线综合| 精品一区二区在线看| 中文av一区特黄| 欧美日精品一区视频| 黄页视频在线91| 亚洲免费看黄网站| 久久影音资源网| 欧美日韩在线播放三区四区| 久久99日本精品| 一区二区三区四区av| 久久久久综合网| 欧美色图激情小说| 国产激情91久久精品导航| 亚洲高清久久久| 国产精品污网站| 日韩精品综合一本久道在线视频| 91女厕偷拍女厕偷拍高清| 久久福利视频一区二区| 亚洲精品国产一区二区三区四区在线| 欧美一卡二卡三卡| 99r精品视频| 免费成人深夜小野草| 亚洲码国产岛国毛片在线| 日韩精品专区在线影院观看| 欧美专区日韩专区| 成人av电影免费在线播放| 久热成人在线视频| 性久久久久久久| 中文字幕人成不卡一区| 欧美大片拔萝卜| 欧美日韩国产影片| 亚洲欧洲美洲综合色网| 精品国产伦一区二区三区观看方式 | 91精品国产综合久久精品app| 成人天堂资源www在线| 久久激情五月激情| 亚洲h精品动漫在线观看| 亚洲色图欧洲色图婷婷| 欧美韩国日本综合| 久久久久久久久久久久电影| 欧美精品三级日韩久久| 色婷婷狠狠综合| 成人av网址在线观看| 麻豆91精品视频| 午夜视频在线观看一区| 亚洲三级免费电影| 国产精品看片你懂得| 精品国产欧美一区二区| 日韩亚洲国产中文字幕欧美| 欧美日韩精品欧美日韩精品| 色婷婷av一区二区三区gif| 成人黄色免费短视频| 国产成人精品网址| 国产高清精品网站| 国产成人精品在线看|