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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? fat16.c

?? MMC/SD操作
?? C
?? 第 1 頁 / 共 4 頁
字號:
#include "partition.h"#include "fat16.h"#include "fat16_config.h"#include <stdlib.h>#include <string.h>/** * \addtogroup fat16 FAT16 support * * This module implements FAT16 read and write access. *  * The following features are supported: * - File names up to 31 characters long. * - Unlimited depth of subdirectories. * - Short 8.3 and long filenames. * - Creating and deleting files. * - Reading and writing from and to files. * - File resizing. * - File sizes of up to 4 gigabytes. *  * @{ *//** * \file * FAT16 implementation. * * \author Roland Riegel *//** * \addtogroup fat16_config FAT16 configuration * Preprocessor defines to configure the FAT16 implementation. *//** * \addtogroup fat16_fs FAT16 access * Basic functions for handling a FAT16 filesystem. *//** * \addtogroup fat16_file FAT16 file functions * Functions for managing files. *//** * \addtogroup fat16_dir FAT16 directory functions * Functions for managing directories. *//** * @} */#define FAT16_CLUSTER_FREE 0x0000#define FAT16_CLUSTER_RESERVED_MIN 0xfff0#define FAT16_CLUSTER_RESERVED_MAX 0xfff6#define FAT16_CLUSTER_BAD 0xfff7#define FAT16_CLUSTER_LAST_MIN 0xfff8#define FAT16_CLUSTER_LAST_MAX 0xffff#define FAT16_DIRENTRY_DELETED 0xe5#define FAT16_DIRENTRY_LFNLAST (1 << 6)#define FAT16_DIRENTRY_LFNSEQMASK ((1 << 6) - 1)/* Each entry within the directory table has a size of 32 bytes * and either contains a 8.3 DOS-style file name or a part of a * long file name, which may consist of several directory table * entries at once. * * multi-byte integer values are stored little-endian! * * 8.3 file name entry: * ==================== * offset  length  description *      0       8  name (space padded) *      8       3  extension (space padded) *     11       1  attributes (FAT16_ATTRIB_*) * * long file name (lfn) entry ordering for a single file name: * =========================================================== * LFN entry n *     ... * LFN entry 2 * LFN entry 1 * 8.3 entry (see above) *  * lfn entry: * ========== * offset  length  description *      0       1  ordinal field *      1       2  unicode character 1 *      3       3  unicode character 2 *      5       3  unicode character 3 *      7       3  unicode character 4 *      9       3  unicode character 5 *     11       1  attribute (always 0x0f) *     12       1  type (reserved, always 0) *     13       1  checksum *     14       2  unicode character 6 *     16       2  unicode character 7 *     18       2  unicode character 8 *     20       2  unicode character 9 *     22       2  unicode character 10 *     24       2  unicode character 11 *     26       2  cluster (unused, always 0) *     28       2  unicode character 12 *     30       2  unicode character 13 *  * The ordinal field contains a descending number, from n to 1. * For the n'th lfn entry the ordinal field is or'ed with 0x40. * For deleted lfn entries, the ordinal field is set to 0xe5. */struct fat16_header_struct{    uint32_t size;    uint32_t fat_offset;    uint32_t fat_size;    uint16_t sector_size;    uint16_t cluster_size;    uint32_t root_dir_offset;    uint32_t cluster_zero_offset;};struct fat16_fs_struct{    struct partition_struct* partition;    struct fat16_header_struct header;};struct fat16_file_struct{    struct fat16_fs_struct* fs;    struct fat16_dir_entry_struct dir_entry;    uint32_t pos;};struct fat16_dir_struct{    struct fat16_fs_struct* fs;    struct fat16_dir_entry_struct dir_entry;    uint16_t entry_next;};struct fat16_read_callback_arg{    uint16_t entry_cur;    uint16_t entry_num;    uint32_t entry_offset;    uint8_t byte_count;};static uint8_t fat16_read_header(struct fat16_fs_struct* fs);static uint8_t fat16_read_root_dir_entry(const struct fat16_fs_struct* fs, uint16_t entry_num, struct fat16_dir_entry_struct* dir_entry);static uint8_t fat16_read_sub_dir_entry(const struct fat16_fs_struct* fs, uint16_t entry_num, const struct fat16_dir_entry_struct* parent, struct fat16_dir_entry_struct* dir_entry);static uint8_t fat16_dir_entry_seek_callback(uint8_t* buffer, uint32_t offset, void* p);static uint8_t fat16_dir_entry_read_callback(uint8_t* buffer, uint32_t offset, void* p);static uint8_t fat16_interpret_dir_entry(struct fat16_dir_entry_struct* dir_entry, const uint8_t* raw_entry);static uint16_t fat16_get_next_cluster(const struct fat16_fs_struct* fs, uint16_t cluster_num);static uint16_t fat16_append_cluster(const struct fat16_fs_struct* fs, uint16_t cluster_num);static uint8_t fat16_free_cluster(struct fat16_fs_struct* fs, uint16_t cluster_num);static uint8_t fat16_write_dir_entry(struct fat16_fs_struct* fs, const struct fat16_dir_entry_struct* dir_entry);/** * \ingroup fat16_fs * Opens a FAT16 filesystem. * * \param[in] partition Discriptor of partition on which the filesystem resides. * \returns 0 on error, a FAT16 filesystem descriptor on success. * \see fat16_open */struct fat16_fs_struct* fat16_open(struct partition_struct* partition){    if(!partition ||#if FAT16_WRITE_SUPPORT       !partition->device_write#else       0#endif      )        return 0;    struct fat16_fs_struct* fs = malloc(sizeof(*fs));    if(!fs)        return 0;    memset(fs, 0, sizeof(*fs));    fs->partition = partition;    if(!fat16_read_header(fs))    {        free(fs);        return 0;    }        return fs;}/** * \ingroup fat16_fs * Closes a FAT16 filesystem. * * When this function returns, the given filesystem descriptor * will be invalid. * * \param[in] fs The filesystem to close. * \see fat16_open */void fat16_close(struct fat16_fs_struct* fs){    if(!fs)        return;    free(fs);}/** * \ingroup fat16_fs * Reads and parses the header of a FAT16 filesystem. * * \param[inout] fs The filesystem for which to parse the header. * \returns 0 on failure, 1 on success. */uint8_t fat16_read_header(struct fat16_fs_struct* fs){    uint8_t buffer[25];    struct partition_struct* partition;    struct fat16_header_struct* header;        if(!fs || !fs->partition)        return 0;    partition = fs->partition;    header = &fs->header;        if(partition->type != PARTITION_TYPE_FAT16 &&       partition->type != PARTITION_TYPE_FAT16_LBA)        return 0;    uint32_t partition_offset = partition->offset * 512;    if(!partition->device_read(partition_offset + 0x0b, buffer, sizeof(buffer)))        return 0;    memset(header, 0, sizeof(*header));        uint16_t bytes_per_sector = ((uint16_t) buffer[0x00]) |                                ((uint16_t) buffer[0x01] << 8);    uint8_t sectors_per_cluster = buffer[0x02];    uint16_t reserved_sectors = ((uint16_t) buffer[0x03]) |                                ((uint16_t) buffer[0x04] << 8);    uint8_t fat_copies = buffer[0x05];    uint16_t max_root_entries = ((uint16_t) buffer[0x06]) |                                ((uint16_t) buffer[0x07] << 8);    uint16_t sectors_per_fat = ((uint16_t) buffer[0x0b]) |                               ((uint16_t) buffer[0x0c] << 8);    uint32_t sector_count = ((uint32_t) buffer[0x15]) |                            ((uint32_t) buffer[0x16] << 8) |                            ((uint32_t) buffer[0x17] << 16) |                            ((uint32_t) buffer[0x18] << 24);        header->size = sector_count * bytes_per_sector;    header->fat_offset = /* jump to partition */                         partition_offset +                         /* jump to fat */                         (uint32_t) reserved_sectors * bytes_per_sector;    header->fat_size = (uint32_t) sectors_per_fat * bytes_per_sector;    header->sector_size = bytes_per_sector;    header->cluster_size = (uint32_t) bytes_per_sector * sectors_per_cluster;    header->root_dir_offset = /* jump to fats */                              header->fat_offset +                              /* jump to root directory entries */                              (uint32_t) fat_copies * sectors_per_fat * bytes_per_sector;    header->cluster_zero_offset = /* jump to root directory entries */                                  header->root_dir_offset +                                  /* skip root directory entries */                                  (uint32_t) max_root_entries * 32;    return 1;}/** * \ingroup fat16_fs * Reads a directory entry of the root directory. * * \param[in] fs Descriptor of file system to use. * \param[in] entry_num The index of the directory entry to read. * \param[out] dir_entry Directory entry descriptor which will get filled. * \returns 0 on failure, 1 on success * \see fat16_read_sub_dir_entry, fat16_read_dir_entry_by_path */uint8_t fat16_read_root_dir_entry(const struct fat16_fs_struct* fs, uint16_t entry_num, struct fat16_dir_entry_struct* dir_entry){    if(!fs || !dir_entry)        return 0;    /* we read from the root directory entry */    const struct fat16_header_struct* header = &fs->header;    device_read_interval_t device_read_interval = fs->partition->device_read_interval;    uint8_t buffer[32];    /* seek to the n-th entry */    struct fat16_read_callback_arg arg;    memset(&arg, 0, sizeof(arg));    arg.entry_num = entry_num;    if(!device_read_interval(header->root_dir_offset,                             buffer,                             sizeof(buffer),                             header->cluster_zero_offset - header->root_dir_offset,                             fat16_dir_entry_seek_callback,                             &arg) ||       arg.entry_offset == 0      )        return 0;    /* read entry */    memset(dir_entry, 0, sizeof(*dir_entry));    if(!device_read_interval(arg.entry_offset,                             buffer,                             sizeof(buffer),                             arg.byte_count,                             fat16_dir_entry_read_callback,                             dir_entry))        return 0;    return dir_entry->long_name[0] != '\0' ? 1 : 0;}/** * \ingroup fat16_fs * Reads a directory entry of a given parent directory. * * \param[in] fs Descriptor of file system to use. * \param[in] entry_num The index of the directory entry to read. * \param[in] parent Directory entry descriptor in which to read directory entry. * \param[out] dir_entry Directory entry descriptor which will get filled. * \returns 0 on failure, 1 on success * \see fat16_read_root_dir_entry, fat16_read_dir_entry_by_path */uint8_t fat16_read_sub_dir_entry(const struct fat16_fs_struct* fs, uint16_t entry_num, const struct fat16_dir_entry_struct* parent, struct fat16_dir_entry_struct* dir_entry){    if(!fs || !parent || !dir_entry)        return 0;    /* we are in a parent directory and want to search within its directory entry table */    if(!(parent->attributes & FAT16_ATTRIB_DIR))        return 0;    /* loop through all clusters of the directory */    uint8_t buffer[32];    uint32_t cluster_offset;    uint16_t cluster_size = fs->header.cluster_size;    uint16_t cluster_num = parent->cluster;    struct fat16_read_callback_arg arg;    while(1)    {        /* calculate new cluster offset */        cluster_offset = fs->header.cluster_zero_offset + (uint32_t) (cluster_num - 2) * cluster_size;        /* seek to the n-th entry */        memset(&arg, 0, sizeof(arg));        arg.entry_num = entry_num;        if(!fs->partition->device_read_interval(cluster_offset,                                                buffer,                                                sizeof(buffer),                                                cluster_size,                                                fat16_dir_entry_seek_callback,                                                &arg)          )            return 0;        /* check if we found the entry */        if(arg.entry_offset)            break;        /* get number of next cluster */        if(!(cluster_num = fat16_get_next_cluster(fs, cluster_num)))            return 0; /* directory entry not found */    }    memset(dir_entry, 0, sizeof(*dir_entry));    /* read entry */    if(!fs->partition->device_read_interval(arg.entry_offset,                                            buffer,                                            sizeof(buffer),                                            arg.byte_count,                                            fat16_dir_entry_read_callback,                                            dir_entry))        return 0;    return dir_entry->long_name[0] != '\0' ? 1 : 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人精品一区二区三区四区| 亚洲欧美日韩成人高清在线一区| 3d成人动漫网站| 欧美日韩一区二区三区在线 | 国产精品小仙女| 丁香亚洲综合激情啪啪综合| 成人网在线免费视频| 成人aaaa免费全部观看| 一卡二卡欧美日韩| 亚洲人成在线播放网站岛国| 日韩精品一区二区在线| 久久久久国产精品人| 国产精品网站在线观看| 一区二区三区欧美激情| 亚洲最新视频在线播放| 91女厕偷拍女厕偷拍高清| 美女网站色91| 亚洲人xxxx| 一级中文字幕一区二区| 亚洲女与黑人做爰| 亚洲欧美一区二区三区国产精品| 久久久久久久久97黄色工厂| 欧美精品在线观看播放| 欧美精品色综合| 精品国产凹凸成av人导航| 精品久久久久久久人人人人传媒| 久久综合九色综合欧美98| 国产精品色在线观看| 亚洲男人的天堂网| 日本不卡123| 国产成人综合在线播放| 日本道在线观看一区二区| 欧美三级电影网站| 亚洲精品在线观| 亚洲欧洲精品一区二区精品久久久| 亚洲精品欧美激情| 黄色资源网久久资源365| a4yy欧美一区二区三区| 欧美丰满一区二区免费视频| 国产三级一区二区三区| 亚洲欧美日韩中文字幕一区二区三区 | 狠狠色丁香婷婷综合| 国产69精品久久久久毛片| 欧美性生活大片视频| 久久综合网色—综合色88| 亚洲精品国产一区二区精华液| 美女久久久精品| 色婷婷av一区二区三区gif| 精品国产免费一区二区三区香蕉| 国产精品久久久久久妇女6080| 天堂av在线一区| 91亚洲精品久久久蜜桃网站 | 美女尤物国产一区| 91在线一区二区三区| 精品三级在线看| 一区二区三区不卡视频| 国产成人精品亚洲777人妖| 欧美日本在线播放| 一区二区免费看| av中文字幕一区| 久久久久国产成人精品亚洲午夜| 亚洲国产成人va在线观看天堂| 福利一区福利二区| 欧美电影免费观看完整版| 性欧美大战久久久久久久久| 一本在线高清不卡dvd| 久久九九全国免费| 国产精品自拍毛片| 久久夜色精品一区| 久久99精品久久久久久国产越南| 欧美私模裸体表演在线观看| 亚洲人成电影网站色mp4| av在线不卡电影| 国产精品久久久久永久免费观看| 激情五月激情综合网| 欧美xxxx在线观看| 国内精品伊人久久久久影院对白| 欧美一级免费观看| 日韩中文字幕1| 欧美肥妇free| 日韩国产一二三区| 日韩精品一区二区三区蜜臀| 久久99久久久久久久久久久| 日韩精品一区二区三区视频在线观看| 日本不卡不码高清免费观看| 日韩三级视频中文字幕| 国产自产v一区二区三区c| 久久一区二区视频| 成人免费视频视频在线观看免费 | 欧美xxxx在线观看| 国产成人精品三级| 亚洲免费在线看| 欧美人体做爰大胆视频| 日韩vs国产vs欧美| 久久先锋影音av鲁色资源网| 国产成人亚洲综合a∨猫咪| 中文字幕+乱码+中文字幕一区| 91影视在线播放| 亚洲电影第三页| 精品国产麻豆免费人成网站| 国产精品123| 亚洲免费看黄网站| 欧美人牲a欧美精品| 国产一区二区三区免费播放 | 欧美视频一区在线| 紧缚奴在线一区二区三区| 国产精品色哟哟网站| 在线一区二区三区四区五区| 免费观看成人鲁鲁鲁鲁鲁视频| 日韩免费视频一区二区| 不卡av免费在线观看| 亚洲成人激情综合网| 久久久国际精品| 日本高清免费不卡视频| 黄色资源网久久资源365| 一区二区三区在线视频观看 | 99久久精品久久久久久清纯| 午夜不卡在线视频| 国产精品乱子久久久久| 欧美精品国产精品| 99精品欧美一区二区三区小说| 国产午夜精品美女毛片视频| 欧美日韩你懂的| 成人91在线观看| 久久av老司机精品网站导航| 亚洲一区二区免费视频| 久久在线免费观看| 日韩写真欧美这视频| 91色九色蝌蚪| 国产精品白丝jk黑袜喷水| 无码av中文一区二区三区桃花岛| 国产精品高潮呻吟| 精品国产乱码久久久久久久| 欧美性生交片4| 91污在线观看| 成人永久aaa| 国产成人综合亚洲网站| 韩国午夜理伦三级不卡影院| 亚洲成av人**亚洲成av**| 中文字幕亚洲综合久久菠萝蜜| 精品久久国产97色综合| 51精品国自产在线| 欧美乱熟臀69xxxxxx| 日本精品视频一区二区| 不卡在线观看av| 成人美女视频在线观看18| 国产精品系列在线播放| 狠狠色狠狠色综合日日91app| 日韩国产欧美在线播放| 视频一区中文字幕| 亚洲国产精品麻豆| 亚洲一区二区三区美女| 伊人开心综合网| 亚洲视频一区二区在线| 亚洲色图视频网站| 亚洲精品老司机| 丝袜亚洲精品中文字幕一区| 一区二区三区四区激情| 亚洲精品久久嫩草网站秘色| 亚洲一区精品在线| 丝袜a∨在线一区二区三区不卡| 亚洲成人资源在线| 热久久国产精品| 国产在线一区观看| 成人精品国产福利| 色婷婷精品大视频在线蜜桃视频| 日本高清无吗v一区| 欧美精品免费视频| 日韩西西人体444www| 精品国产自在久精品国产| 亚洲国产精品v| 一区二区成人在线视频| 性欧美疯狂xxxxbbbb| 久久99蜜桃精品| 成人免费看片app下载| 成人av在线影院| 欧美自拍丝袜亚洲| 日韩一级片网址| 国产精品美女www爽爽爽| 依依成人精品视频| 久草精品在线观看| 99久久99久久综合| 91.成人天堂一区| 日本一区二区三区四区在线视频| 亚洲精品美国一| 美腿丝袜亚洲综合| 91最新地址在线播放| 欧美精品乱人伦久久久久久| 国产人妖乱国产精品人妖| 一区二区三区视频在线观看 | 久久亚洲一区二区三区明星换脸| 国产精品丝袜久久久久久app| 亚洲欧美激情小说另类| 精品一区二区三区在线观看| 91免费版pro下载短视频| 精品国产91久久久久久久妲己| 中文字幕一区二区三区色视频| 欧美a一区二区| 日本韩国一区二区三区视频| 26uuu欧美|