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

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

?? fat_open.c

?? uCOS uCGUI uCFS 在ADS下調試通過 LPC2292
?? 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一区二区三区免费野_久草精品视频
日韩欧美一区中文| 18成人在线观看| 中文字幕在线不卡国产视频| 亚洲成人1区2区| 成人av电影在线播放| 日韩欧美一级二级三级| 亚洲一区二区三区在线看| 国产福利不卡视频| 日韩欧美中文一区| 亚洲一级电影视频| 99久久免费国产| 久久久国产综合精品女国产盗摄| 日日夜夜精品视频免费| 91视视频在线观看入口直接观看www | 久久99九九99精品| 欧美亚洲国产一区二区三区va | 中文字幕亚洲综合久久菠萝蜜| 麻豆精品视频在线观看视频| 欧美色综合网站| 一区二区三区四区视频精品免费| 国产精品一二三区在线| 精品久久久久久久久久久院品网| 日韩中文欧美在线| 欧美日韩国产一区二区三区地区| 一区二区三区在线视频免费| 成人av电影免费在线播放| 国产日韩精品久久久| 国产乱码精品一区二区三区忘忧草 | 久久久久国色av免费看影院| 奇米影视一区二区三区| 欧美一区二区三区视频| 午夜av一区二区| 4438成人网| 久久激情五月婷婷| 亚洲精品一区二区在线观看| 久久99精品国产| 久久久久国产精品麻豆| 国产成人aaaa| 亚洲欧美中日韩| 日本韩国一区二区三区视频| 亚洲精品视频在线观看免费| 91首页免费视频| 亚洲电影你懂得| 欧美一二三四在线| 久久国产精品一区二区| 日韩精品一区二区三区四区视频| 国产在线看一区| 国产精品毛片久久久久久久| 91美女精品福利| 日韩精品每日更新| 久久综合99re88久久爱| 成人免费福利片| 亚洲国产精品久久久男人的天堂| 欧美电影在哪看比较好| 国产在线播放一区| 亚洲视频免费看| 欧美浪妇xxxx高跟鞋交| 狠狠色丁香婷婷综合| 国产精品国产a| 欧美高清视频在线高清观看mv色露露十八| 天涯成人国产亚洲精品一区av| 精品久久免费看| 色婷婷综合久久久| 精品无人区卡一卡二卡三乱码免费卡| 国产日韩欧美精品电影三级在线 | 亚洲另类一区二区| 日韩欧美一区二区免费| 99久久综合色| 久久成人免费日本黄色| 亚洲日韩欧美一区二区在线| 678五月天丁香亚洲综合网| 丁香天五香天堂综合| 亚洲高清视频的网址| 久久精品视频一区二区三区| 在线视频欧美区| 国产伦精品一区二区三区免费| 亚洲日本丝袜连裤袜办公室| 在线不卡a资源高清| 成人av小说网| 久久电影国产免费久久电影| 亚洲乱码日产精品bd| www久久精品| 欧美色手机在线观看| 成熟亚洲日本毛茸茸凸凹| 肉肉av福利一精品导航| 日韩毛片精品高清免费| 日韩一级高清毛片| 91极品美女在线| 北条麻妃国产九九精品视频| 国产在线一区二区综合免费视频| 亚洲妇女屁股眼交7| 国产欧美一区二区精品仙草咪| 欧美日本视频在线| 在线视频综合导航| 99re这里只有精品视频首页| 国产精品1区2区| 国产自产v一区二区三区c| 五月婷婷激情综合| 性做久久久久久免费观看| 亚洲区小说区图片区qvod| 欧美韩国日本综合| 久久免费看少妇高潮| 日韩欧美一级二级三级| 欧美一区二区在线看| 欧美亚洲丝袜传媒另类| 91小宝寻花一区二区三区| 成人av在线一区二区三区| 高清国产一区二区| 成人性色生活片| 风间由美一区二区av101| 国产白丝网站精品污在线入口| 国产在线精品一区二区不卡了| 美日韩一级片在线观看| 日本中文字幕一区二区有限公司| 亚洲成人av一区二区三区| 亚洲自拍偷拍麻豆| 亚洲一区二区三区爽爽爽爽爽| 亚洲最大的成人av| 亚洲综合色噜噜狠狠| 一区二区欧美精品| 亚洲成人在线免费| 免费人成精品欧美精品| 奇米在线7777在线精品| 免费精品视频最新在线| 免费成人深夜小野草| 美女在线观看视频一区二区| 激情综合色综合久久| 国产精品一区在线观看你懂的| 国产传媒一区在线| 国产不卡视频在线观看| 懂色av一区二区三区蜜臀| 一本色道久久综合亚洲aⅴ蜜桃| 色哟哟国产精品免费观看| 欧美在线短视频| 日韩一级高清毛片| 国产欧美日韩不卡| 亚洲一区在线免费观看| 日韩精品亚洲专区| 国产成人免费高清| 在线视频一区二区免费| 日韩亚洲欧美在线| 中文字幕精品在线不卡| 亚洲一区日韩精品中文字幕| 三级成人在线视频| 国产99精品在线观看| 91高清视频免费看| 日韩欧美区一区二| 亚洲欧洲日韩一区二区三区| 日韩av电影一区| 成人免费观看av| 欧美一级在线观看| 亚洲视频在线观看一区| 免费一级片91| 92精品国产成人观看免费| 日韩一区国产二区欧美三区| 国产精品久久久久久久久动漫| 天天爽夜夜爽夜夜爽精品视频| 国产精品一区二区久久精品爱涩 | 欧美精品亚洲二区| 国产精品国模大尺度视频| 丝袜美腿成人在线| 成人午夜激情在线| 日韩欧美国产三级电影视频| 国产精品乱码久久久久久| 日本大胆欧美人术艺术动态| fc2成人免费人成在线观看播放| 欧美一区午夜精品| 亚洲精品视频免费看| 国产成人免费在线视频| 欧美片网站yy| 一区二区三区欧美视频| 东方aⅴ免费观看久久av| 欧美人动与zoxxxx乱| 亚洲人成7777| 国产成人综合在线播放| 日韩欧美一区二区不卡| 亚洲午夜久久久久| 99re热这里只有精品免费视频 | 最新欧美精品一区二区三区| 久久99日本精品| 7799精品视频| 亚洲无线码一区二区三区| 99re成人在线| 综合久久综合久久| 成人免费高清在线| 欧美激情自拍偷拍| 成人在线视频一区| 久久精品人人做人人爽97| 麻豆久久久久久| 日韩午夜激情电影| 久久精品国产秦先生| 91精品国产综合久久精品| 亚洲高清免费观看高清完整版在线观看| 97成人超碰视| 亚洲欧美电影院| 91激情在线视频| 亚洲一区二区四区蜜桃| 欧美性感一类影片在线播放| 依依成人综合视频| 欧美日韩精品一区二区三区四区 |