亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产亚洲成年网址在线观看| 欧美午夜精品一区二区三区 | 国产日韩欧美一区二区三区乱码 | 国产一区二区伦理| av资源站一区| 欧美成人国产一区二区| 一区二区视频在线| 成人小视频在线| 日韩午夜av电影| 亚洲一区二区在线观看视频| 免费在线成人网| 中文字幕在线观看不卡| 美女www一区二区| 欧美色网站导航| 中文字幕在线不卡一区| 国产成人自拍网| 精品国产一区二区三区不卡| 日韩电影在线一区二区三区| 色欧美片视频在线观看| 亚洲国产精品成人综合 | 麻豆久久久久久| 在线不卡的av| 一区二区三区欧美在线观看| 91在线精品秘密一区二区| 日本午夜精品视频在线观看| 日本乱人伦一区| 亚洲乱码一区二区三区在线观看| 粉嫩aⅴ一区二区三区四区| 精品国精品自拍自在线| 狠狠色丁香久久婷婷综合_中| 欧美一区二区美女| 秋霞av亚洲一区二区三| 欧美一区二区三区婷婷月色| 日韩电影在线一区二区三区| 日韩一区二区免费视频| 首页国产欧美日韩丝袜| 欧美一区二区在线播放| 麻豆久久久久久| 久久久精品影视| 福利电影一区二区| 国产精品免费aⅴ片在线观看| 成人激情图片网| 中文字幕一区二区三区av| 99精品国产91久久久久久 | 久久久久久久久蜜桃| 国产精品一品二品| 欧美激情一区二区三区在线| 国产sm精品调教视频网站| 日韩不卡一区二区| 五月婷婷激情综合网| 色婷婷av一区二区三区之一色屋| 中文在线一区二区| 在线免费精品视频| 日本在线不卡一区| 日韩一区二区高清| 国产xxx精品视频大全| 综合亚洲深深色噜噜狠狠网站| 91丨九色丨国产丨porny| 亚洲一区二区在线观看视频| 日韩精品专区在线| 成人午夜电影网站| 性做久久久久久免费观看| 日韩欧美不卡在线观看视频| 国产精品99精品久久免费| 亚洲日本青草视频在线怡红院| 欧美精品v日韩精品v韩国精品v| 久久国产精品72免费观看| 中文字幕精品综合| 欧美精品乱人伦久久久久久| 国产精品一区二区黑丝| 美女一区二区久久| 中文字幕乱码日本亚洲一区二区 | 奇米色一区二区三区四区| 亚洲精品在线三区| 色吧成人激情小说| 精品一区二区三区免费| 亚洲欧美另类图片小说| 精品sm捆绑视频| 欧美伊人久久久久久久久影院| 国产一区二区三区四| 亚洲国产成人av好男人在线观看| 久久精品在线免费观看| 欧美亚洲日本一区| 成人免费毛片aaaaa**| 免费xxxx性欧美18vr| 亚洲图片你懂的| 久久久久久9999| 欧美一区三区二区| 欧美中文字幕一区二区三区亚洲| 国产中文字幕精品| 五月婷婷综合激情| 一个色妞综合视频在线观看| 国产午夜亚洲精品理论片色戒| 777xxx欧美| 欧美日韩在线一区二区| 97久久精品人人澡人人爽| 国产在线精品一区二区夜色 | 亚洲欧洲另类国产综合| 精品国产在天天线2019| 91精品国产日韩91久久久久久| 91亚洲永久精品| 成人高清在线视频| 国产高清不卡二三区| 九色综合狠狠综合久久| 免费成人在线影院| 午夜电影网一区| 夜夜精品视频一区二区| 亚洲人成7777| 亚洲欧美偷拍卡通变态| 日韩一区在线看| 国产精品久久久久影院| 日本一区二区高清| 日韩理论片一区二区| 精品成人在线观看| 日韩欧美视频一区| 日韩免费电影网站| 精品久久久网站| 精品成人一区二区| 精品免费国产二区三区| 欧美va在线播放| 欧美一区二区视频在线观看2022| 欧美日韩1区2区| 91精品国产一区二区三区| 6080午夜不卡| 2024国产精品| 国产欧美一区二区三区鸳鸯浴 | 日韩av网站免费在线| 婷婷成人综合网| 精品一区二区免费| 国产精品2024| aaa欧美大片| 欧美性色aⅴ视频一区日韩精品| 一本一道久久a久久精品综合蜜臀| 日本乱人伦一区| 91精品国产欧美一区二区成人| 日韩一级大片在线| 欧美韩国日本不卡| 伊人色综合久久天天| 日韩二区三区四区| 国产成人av资源| 久久久久99精品国产片| 国产精品久久久久久久久动漫| 亚洲欧美电影院| 水野朝阳av一区二区三区| 国产在线精品不卡| 日本乱人伦aⅴ精品| 日韩一区二区免费视频| 国产精品久久三区| 天涯成人国产亚洲精品一区av| 久久精品国产久精国产爱| 一区二区三区国产精华| 三级成人在线视频| 国产成人自拍在线| 欧美日韩三级在线| 国产午夜精品久久久久久免费视 | 国产高清亚洲一区| 色域天天综合网| 精品少妇一区二区三区在线播放| 中文字幕亚洲欧美在线不卡| 日韩精品成人一区二区在线| 国产91清纯白嫩初高中在线观看| 欧美视频一区二区三区在线观看| 欧美成人a∨高清免费观看| 国产精品久久久久久久久免费丝袜| 亚洲国产sm捆绑调教视频| 国产盗摄女厕一区二区三区| 欧美色欧美亚洲另类二区| 久久精品人人做人人爽97| 日韩国产在线一| 91豆麻精品91久久久久久| 久久老女人爱爱| 日本免费在线视频不卡一不卡二| 国产剧情一区在线| 在线观看av一区二区| 国产精品区一区二区三区| 韩国视频一区二区| 7777精品伊人久久久大香线蕉完整版| 国产精品麻豆欧美日韩ww| 久久爱www久久做| 国产精品人成在线观看免费| 久久精品国产一区二区三| 欧美色图激情小说| 一区二区高清免费观看影视大全| 成人午夜免费av| 精品999在线播放| 美女一区二区三区在线观看| 56国语精品自产拍在线观看| 亚洲制服丝袜在线| 欧美中文字幕一区二区三区| 18欧美亚洲精品| 不卡欧美aaaaa| 日本一区二区三区免费乱视频| 狠狠色2019综合网| 日韩午夜在线观看视频| 麻豆精品国产91久久久久久| 欧美一级生活片| 看片网站欧美日韩| 精品国免费一区二区三区| 久久精品国产久精国产爱| 精品日韩av一区二区|