[2fb88ea] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Oleg Romanenko
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup fs
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | * @file exfat_dentry.c
|
---|
| 35 | * @brief Functions that work with exFAT directory entries.
|
---|
| 36 | */
|
---|
| 37 |
|
---|
| 38 | #include "exfat_dentry.h"
|
---|
| 39 | #include <ctype.h>
|
---|
| 40 | #include <str.h>
|
---|
| 41 | #include <errno.h>
|
---|
| 42 | #include <byteorder.h>
|
---|
| 43 | #include <assert.h>
|
---|
| 44 |
|
---|
| 45 | exfat_dentry_clsf_t exfat_classify_dentry(const exfat_dentry_t *d)
|
---|
| 46 | {
|
---|
| 47 | switch (d->type) {
|
---|
| 48 | case EXFAT_TYPE_VOLLABEL:
|
---|
| 49 | return EXFAT_DENTRY_VOLLABEL;
|
---|
| 50 | case EXFAT_TYPE_BITMAP:
|
---|
| 51 | return EXFAT_DENTRY_BITMAP;
|
---|
| 52 | case EXFAT_TYPE_UCTABLE:
|
---|
| 53 | return EXFAT_DENTRY_UCTABLE;
|
---|
| 54 | case EXFAT_TYPE_GUID:
|
---|
| 55 | return EXFAT_DENTRY_GUID;
|
---|
| 56 | case EXFAT_TYPE_FILE:
|
---|
| 57 | return EXFAT_DENTRY_FILE;
|
---|
| 58 | case EXFAT_TYPE_STREAM:
|
---|
| 59 | return EXFAT_DENTRY_STREAM;
|
---|
| 60 | case EXFAT_TYPE_NAME:
|
---|
| 61 | return EXFAT_DENTRY_NAME;
|
---|
| 62 | case EXFAT_TYPE_UNUSED:
|
---|
| 63 | return EXFAT_DENTRY_LAST;
|
---|
| 64 | default:
|
---|
| 65 | if (d->type & EXFAT_TYPE_USED)
|
---|
| 66 | return EXFAT_DENTRY_SKIP;
|
---|
[042a725] | 67 | else
|
---|
| 68 | return EXFAT_DENTRY_FREE;
|
---|
[2fb88ea] | 69 | }
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | uint16_t exfat_name_hash(const uint16_t *name)
|
---|
| 73 | {
|
---|
| 74 | /* TODO */
|
---|
| 75 | return 0;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | void exfat_set_checksum(const exfat_dentry_t *d, uint16_t *chksum)
|
---|
| 79 | {
|
---|
| 80 | /* TODO */
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[1f78546] | 83 | void exfat_dentry_get_name(const exfat_name_dentry_t *name, size_t size, uint16_t *dst, size_t *offset)
|
---|
[2fb88ea] | 84 | {
|
---|
[1f78546] | 85 | size_t i=0;
|
---|
| 86 | while(i<EXFAT_NAME_PART_LEN && *offset < size) {
|
---|
| 87 | dst[*offset] = uint16_t_le2host(name->name[i]);
|
---|
| 88 | i++;
|
---|
| 89 | (*offset)++;
|
---|
| 90 | }
|
---|
| 91 | dst[*offset] = '\0';
|
---|
[2fb88ea] | 92 | }
|
---|
| 93 |
|
---|
[1f78546] | 94 | void exfat_dentry_set_name(const uint16_t *src, size_t *offset, exfat_name_dentry_t *name)
|
---|
[2fb88ea] | 95 | {
|
---|
| 96 | /* TODO */
|
---|
[1f78546] | 97 | size_t idx=0;
|
---|
| 98 | while (src[*offset] && idx < EXFAT_NAME_PART_LEN) {
|
---|
| 99 | name->name[idx] = src[*offset];
|
---|
| 100 | (*offset)++;
|
---|
| 101 | idx++;
|
---|
| 102 | }
|
---|
[2fb88ea] | 103 | }
|
---|
| 104 |
|
---|
| 105 | bool exfat_valid_char(wchar_t ch)
|
---|
| 106 | {
|
---|
| 107 | /* TODO */
|
---|
[04a153f] | 108 | return true;
|
---|
[2fb88ea] | 109 | }
|
---|
| 110 |
|
---|
| 111 | bool exfat_valid_name(const char *name)
|
---|
| 112 | {
|
---|
| 113 | /* TODO */
|
---|
[04a153f] | 114 | return true;
|
---|
[2fb88ea] | 115 | }
|
---|
| 116 |
|
---|
| 117 | /**
|
---|
| 118 | * @}
|
---|
| 119 | */
|
---|