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

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

?? fat16.c

?? MMC/SD操作
?? C
?? 第 1 頁 / 共 4 頁
字號:
int16_t fat16_read_file(struct fat16_file_struct* fd, uint8_t* buffer, uint16_t buffer_len){    /* check arguments */    if(!fd || !buffer || buffer_len < 1)        return -1;    /* determine number of bytes to read */    if(fd->pos + buffer_len > fd->dir_entry.file_size)        buffer_len = fd->dir_entry.file_size - fd->pos;    if(buffer_len == 0)        return 0;        uint16_t cluster_size = fd->fs->header.cluster_size;    uint16_t cluster_num = fd->dir_entry.cluster;    uint16_t buffer_left = buffer_len;    uint16_t first_cluster_offset;    /* find cluster in which to start reading */    if(cluster_num)    {        uint32_t pos = fd->pos;        while(pos >= cluster_size)        {            pos -= cluster_size;            cluster_num = fat16_get_next_cluster(fd->fs, cluster_num);            if(!cluster_num)                return -1;        }        first_cluster_offset = pos;    }    else    {        return -1;    }        /* read data */    while(1)    {        /* calculate data size to copy from cluster */        uint32_t cluster_offset = fd->fs->header.cluster_zero_offset +                                  (uint32_t) (cluster_num - 2) * cluster_size + first_cluster_offset;        uint16_t copy_length = cluster_size - first_cluster_offset;        if(copy_length > buffer_left)            copy_length = buffer_left;        /* read data */        if(!fd->fs->partition->device_read(cluster_offset, buffer, copy_length))            return buffer_len - buffer_left;        /* calculate new file position */        buffer += copy_length;        buffer_left -= copy_length;        fd->pos += copy_length;        /* check if we are done */        if(buffer_left == 0)            break;                /* we are on a cluster boundary, so get the next cluster */        if((cluster_num = fat16_get_next_cluster(fd->fs, cluster_num)))            first_cluster_offset = 0;        else            return buffer_len - buffer_left;    }    return buffer_len;}/** * \ingroup fat16_file * Writes data to a file. *  * The data is written to the current file location. * * \param[in] fd The file handle of the file to which to write. * \param[in] buffer The buffer from which to read the data to be written. * \param[in] buffer_len The amount of data to write. * \returns The number of bytes written, 0 on disk full, or -1 on failure. * \see fat16_read_file */int16_t fat16_write_file(struct fat16_file_struct* fd, const uint8_t* buffer, uint16_t buffer_len){#if FAT16_WRITE_SUPPORT    /* check arguments */    if(!fd || !buffer || buffer_len < 1)        return -1;    if(fd->pos > fd->dir_entry.file_size)        return -1;    uint16_t cluster_size = fd->fs->header.cluster_size;    uint16_t cluster_num = fd->dir_entry.cluster;    uint16_t buffer_left = buffer_len;    uint16_t first_cluster_offset = 0;    /* find cluster in which to start writing */    if(cluster_num)    {        uint32_t pos = fd->pos;        while(pos >= cluster_size)        {            pos -= cluster_size;            cluster_num = fat16_get_next_cluster(fd->fs, cluster_num);            if(!cluster_num && pos == 0)                /* the file exactly ends on a cluster boundary, and we append to it */                cluster_num = fat16_append_cluster(fd->fs, cluster_num);            if(!cluster_num)                return -1;        }        first_cluster_offset = pos;    }    else    {        fd->dir_entry.cluster = cluster_num = fat16_append_cluster(fd->fs, 0);        if(!cluster_num)            return -1;    }        /* write data */    while(1)    {        /* calculate data size to write to cluster */        uint32_t cluster_offset = fd->fs->header.cluster_zero_offset +                                  (uint32_t) (cluster_num - 2) * cluster_size + first_cluster_offset;        uint16_t write_length = cluster_size - first_cluster_offset;        if(write_length > buffer_left)            write_length = buffer_left;        /* write data which fits into the current cluster */        if(!fd->fs->partition->device_write(cluster_offset, buffer, write_length))            break;        /* calculate new file position */        buffer += write_length;        buffer_left -= write_length;        fd->pos += write_length;        /* check if we are done */        if(buffer_left == 0)            break;                /* we are on a cluster boundary, so get the next cluster */        uint16_t cluster_num_next = fat16_get_next_cluster(fd->fs, cluster_num);        if(!cluster_num_next)        {            cluster_num_next = fat16_append_cluster(fd->fs, cluster_num);            if(!cluster_num_next)                break;        }        cluster_num = cluster_num_next;                first_cluster_offset = 0;    }    /* update directory entry */    if(fd->pos > fd->dir_entry.file_size)    {        uint32_t size_old = fd->dir_entry.file_size;        /* update file size */        fd->dir_entry.file_size = fd->pos;        /* write directory entry */        if(!fat16_write_dir_entry(fd->fs, &fd->dir_entry))        {            /* We do not return an error here since we actually wrote             * some data to disk. So we calculate the amount of data             * we wrote to disk and which lies within the old file size.             */            buffer_left = fd->pos - size_old;            fd->pos = size_old;        }    }    return buffer_len - buffer_left;#else    return -1;#endif}/** * \ingroup fat16_file * Repositions the read/write file offset. * * Changes the file offset where the next call to fat16_read_file() * or fat16_write_file() starts reading/writing. * * If the new offset is beyond the end of the file, fat16_resize_file() * is implicitly called, i.e. the file is expanded. * * The new offset can be given in different ways determined by * the \c whence parameter: * - \b FAT16_SEEK_SET: \c *offset is relative to the beginning of the file. * - \b FAT16_SEEK_CUR: \c *offset is relative to the current file position. * - \b FAT16_SEEK_END: \c *offset is relative to the end of the file. * * The resulting absolute offset is written to the location the \c offset * parameter points to. *  * \param[in] fd The file decriptor of the file on which to seek. * \param[in,out] offset A pointer to the new offset, as affected by the \c whence *                   parameter. The function writes the new absolute offset *                   to this location before it returns. * \param[in] whence Affects the way \c offset is interpreted, see above. * \returns 0 on failure, 1 on success. */uint8_t fat16_seek_file(struct fat16_file_struct* fd, int32_t* offset, uint8_t whence){    if(!fd || !offset)        return 0;    uint32_t new_pos = fd->pos;    switch(whence)    {        case FAT16_SEEK_SET:            new_pos = *offset;            break;        case FAT16_SEEK_CUR:            new_pos += *offset;            break;        case FAT16_SEEK_END:            new_pos = fd->dir_entry.file_size + *offset;            break;        default:            return 0;    }    if(new_pos > fd->dir_entry.file_size && !fat16_resize_file(fd, new_pos))        return 0;    fd->pos = new_pos;    *offset = new_pos;    return 1;}/** * \ingroup fat16_file * Resizes a file to have a specific size. * * Enlarges or shrinks the file pointed to by the file descriptor to have * exactly the specified size. * * If the file is truncated, all bytes having an equal or larger offset * than the given size are lost. If the file is expanded, the additional * bytes are allocated, but they keep their values. * * \param[in] fd The file decriptor of the file which to resize. * \param[in] size The new size of the file. * \returns 0 on failure, 1 on success. */uint8_t fat16_resize_file(struct fat16_file_struct* fd, uint32_t size){    if(!fd)        return 0;    uint16_t cluster_num = fd->dir_entry.cluster;    uint16_t cluster_size = fd->fs->header.cluster_size;    uint32_t size_new = size;    if(fd->dir_entry.file_size < size)    {        /* check if the file owns a cluster */        if(cluster_num == 0)        {            /* allocate first cluster */            if(!(cluster_num = fat16_append_cluster(fd->fs, cluster_num)))                return 0;            fd->dir_entry.cluster = cluster_num;        }        else        {            /* get last cluster of file */            uint16_t cluster_num_next;            while((cluster_num_next = fat16_get_next_cluster(fd->fs, cluster_num)))            {                cluster_num = cluster_num_next;                size_new -= cluster_size;            }        }        /* append new clusters as needed */        if(size_new > cluster_size)        {            while(1)            {                if(!(cluster_num = fat16_append_cluster(fd->fs, cluster_num)))                    return 0;                if(size_new <= cluster_size)                    break;                size_new -= cluster_size;            }        }        /* write new directory entry */        fd->dir_entry.file_size = size;        if(!fat16_write_dir_entry(fd->fs, &fd->dir_entry))            return 0;    }    else if(fd->dir_entry.file_size > size)    {        /* write new directory entry */        fd->dir_entry.file_size = size;        if(size == 0)            fd->dir_entry.cluster = 0;        if(!fat16_write_dir_entry(fd->fs, &fd->dir_entry))            return 0;                /* get cluster where the file is cut off */        while(size_new > cluster_size)        {            if(!(cluster_num = fat16_get_next_cluster(fd->fs, cluster_num)))                return 0;            size_new -= cluster_size;        }        /* free all clusters no longer needed */        if(size == 0 || (cluster_num = fat16_get_next_cluster(fd->fs, cluster_num)))        {             while(cluster_num)            {                /* get next cluster before freeing the previous one */                uint16_t cluster_num_next = fat16_get_next_cluster(fd->fs, cluster_num);                                /* delete cluster */                fat16_free_cluster(fd->fs, cluster_num);                cluster_num = cluster_num_next;            }        }    }        return 1;}/** * \ingroup fat16_dir * Opens a directory. * * \param[in] fs The filesystem on which the directory to open resides. * \param[in] dir_entry The directory entry which stands for the directory to open. * \returns An opaque directory descriptor on success, 0 on failure. * \see fat16_close_dir */struct fat16_dir_struct* fat16_open_dir(struct fat16_fs_struct* fs, const struct fat16_dir_entry_struct* dir_entry){    if(!fs || !dir_entry || !(dir_entry->attributes & FAT16_ATTRIB_DIR))        return 0;    struct fat16_dir_struct* dd = malloc(sizeof(*dd));    if(!dd)        return 0;        memcpy(&dd->dir_entry, dir_entry, sizeof(*dir_entry));    dd->fs = fs;    dd->entry_next = 0;    return dd;}/** * \ingroup fat16_dir * Closes a directory descriptor. * * This function destroys a directory descriptor which was * previously obtained by calling fat16_open_dir(). When this * function returns, the given descriptor will be invalid. * * \param[in] dd The directory descriptor to close. * \see fat16_open_dir */void fat16_close_dir(struct fat16_dir_struct* dd){    if(dd)        free(dd);}/** * \ingroup fat16_dir * Reads the next directory entry contained within a parent directory. * * \param[in] dd The descriptor of the parent directory from which to read the entry. * \param[out] dir_entry Pointer to a buffer into which to write the directory entry information. * \returns 0 on failure, 1 on success. * \see fat16_reset_dir */uint8_t fat16_read_dir(struct fat16_dir_struct* dd, struct fat16_dir_entry_struct* dir_entry){    if(!dd || !dir_entry)        return 0;    if(dd->dir_entry.cluster == 0)    {        /* read entry from root directory */        if(fat16_read_root_dir_entry(dd->fs, dd->entry_next, dir_entry))        {            ++dd->entry_next;            return 1;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区四区中文字幕| 日韩欧美综合一区| 亚洲日本青草视频在线怡红院 | 亚洲gay无套男同| 欧美理论片在线| 视频一区二区三区在线| 欧美精品乱码久久久久久| 青青草伊人久久| 337p粉嫩大胆噜噜噜噜噜91av| 国产在线精品免费av| 久久久久久免费毛片精品| 国产成人精品网址| 亚洲婷婷综合色高清在线| 色综合天天狠狠| 偷拍日韩校园综合在线| 日韩精品中午字幕| 国产精品中文字幕欧美| 欧美韩日一区二区三区| 在线观看免费一区| 精品影院一区二区久久久| 久久久91精品国产一区二区精品| 成人精品视频一区| 香蕉成人啪国产精品视频综合网| 精品奇米国产一区二区三区| 成人av网站在线观看免费| 亚欧色一区w666天堂| 久久久欧美精品sm网站| 91免费视频观看| 日本在线不卡视频一二三区| 亚洲精品一区二区精华| 91在线视频播放| 青娱乐精品视频| 亚洲精品视频在线看| 欧美一级生活片| 99这里只有久久精品视频| 日韩av中文字幕一区二区| 国产精品第五页| 91精品国产乱码久久蜜臀| 成人免费三级在线| 美女任你摸久久 | 色婷婷综合五月| 久久精品国产亚洲5555| 亚洲欧美日韩系列| 久久蜜桃av一区二区天堂| 欧美色国产精品| a美女胸又www黄视频久久| 免费成人av在线| 亚洲午夜电影在线观看| 国产精品毛片无遮挡高清| 日韩欧美一区二区久久婷婷| 色综合天天性综合| 国产成人午夜精品影院观看视频 | 在线精品视频一区二区三四| 韩国精品一区二区| 图片区小说区区亚洲影院| 国产精品亲子乱子伦xxxx裸| 精品噜噜噜噜久久久久久久久试看| 色婷婷综合久久久久中文 | 午夜不卡在线视频| 亚洲色图欧洲色图婷婷| 久久新电视剧免费观看| 3d成人动漫网站| 欧美偷拍一区二区| 92国产精品观看| 95精品视频在线| 成人激情图片网| 国产91综合一区在线观看| 国产美女一区二区三区| 久久精品国产色蜜蜜麻豆| 免费高清成人在线| 青青国产91久久久久久| 欧美aaaaaa午夜精品| 丝袜脚交一区二区| 天天操天天色综合| 五月婷婷激情综合网| 亚洲一卡二卡三卡四卡五卡| 亚洲美女偷拍久久| 亚洲欧美一区二区三区极速播放| 中文在线一区二区| 国产精品国产成人国产三级| 久久久无码精品亚洲日韩按摩| 欧美r级电影在线观看| 精品国产乱码91久久久久久网站| 日韩一区二区三区视频| 91精品一区二区三区在线观看| 欧美午夜宅男影院| 欧美日韩激情一区二区三区| 91成人免费在线| 91精品免费在线| 精品国产髙清在线看国产毛片| 欧美成va人片在线观看| 国产亚洲一二三区| 国产欧美视频在线观看| 国产精品色在线| 一区二区三区在线免费播放| 亚洲午夜免费视频| 免费在线看成人av| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美日韩国产高清一区二区三区| 欧美日韩一区二区欧美激情| 欧美精品123区| 欧美精品一区二区三区蜜桃 | 中文字幕在线免费不卡| 亚洲色欲色欲www| 亚洲123区在线观看| 久久se这里有精品| 成人精品一区二区三区中文字幕| av在线一区二区| 欧美日本一道本在线视频| 欧美一级午夜免费电影| 久久久久久一级片| 亚洲欧美国产高清| 日韩精品高清不卡| 国产精品996| 欧美亚洲综合一区| 26uuu国产电影一区二区| 成人欧美一区二区三区1314| 午夜精品久久久| 懂色av一区二区三区免费看| 欧美视频精品在线观看| 亚洲精品在线电影| 亚洲欧美日韩系列| 国内成+人亚洲+欧美+综合在线| av在线播放一区二区三区| 欧美久久久久久久久| 国产精品二区一区二区aⅴ污介绍| 午夜成人免费电影| 波多野结衣的一区二区三区| 欧美一区二区播放| 亚洲欧美激情一区二区| 久久电影国产免费久久电影 | 欧美色中文字幕| 国产性做久久久久久| 天天av天天翘天天综合网| 成人午夜免费av| 精品少妇一区二区三区日产乱码 | 亚洲美女屁股眼交| 国产精品一区一区| 欧美日韩免费一区二区三区视频| 久久免费的精品国产v∧| 五月综合激情网| 97se亚洲国产综合自在线 | 欧美日韩精品一二三区| 亚洲国产成人午夜在线一区| 蜜臀av性久久久久蜜臀aⅴ| 欧美天堂一区二区三区| 国产精品传媒入口麻豆| 激情五月婷婷综合网| 欧美日韩国产综合草草| 亚洲三级在线免费| 国产精品羞羞答答xxdd| 欧美sm极限捆绑bd| 日本欧美加勒比视频| 欧美女孩性生活视频| 亚洲综合免费观看高清完整版在线 | 99综合电影在线视频| 久久亚洲精品国产精品紫薇| 色婷婷综合久久久久中文| 久久婷婷成人综合色| 日韩不卡一区二区| 91精品婷婷国产综合久久竹菊| 亚洲人成网站影音先锋播放| jlzzjlzz亚洲女人18| 国产欧美视频一区二区三区| 国产精品综合一区二区三区| 日韩欧美国产精品一区| 首页国产欧美日韩丝袜| 欧美日韩一区二区三区免费看| 亚洲综合无码一区二区| 91麻豆精品视频| 亚洲精品福利视频网站| 色欧美88888久久久久久影院| 国产精品大尺度| 在线一区二区观看| 亚洲在线视频网站| 欧美日韩成人在线| 日产欧产美韩系列久久99| 欧美一区二区三区四区久久| 午夜av一区二区| 日韩美女视频一区二区在线观看| 免播放器亚洲一区| 久久综合av免费| 国产不卡视频一区二区三区| 中文字幕一区二区在线观看| 99久久精品一区| 亚洲高清视频在线| 日韩一区二区三区视频| 国产盗摄视频一区二区三区| 国产日韩视频一区二区三区| 97aⅴ精品视频一二三区| 亚洲成av人片| 久久这里只有精品首页| 成人激情校园春色| 亚洲福利视频导航| 精品成人一区二区三区四区| 国产成人免费视频| 夜夜嗨av一区二区三区网页| 欧美日本视频在线| 国产成人免费9x9x人网站视频| 亚洲精品中文在线影院|