Rev 3504 | Rev 3628 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3504 | Rev 3505 | ||
---|---|---|---|
Line 33... | Line 33... | ||
33 | /** |
33 | /** |
34 | * @file fat_dentry.c |
34 | * @file fat_dentry.c |
35 | * @brief Functions that work with FAT directory entries. |
35 | * @brief Functions that work with FAT directory entries. |
36 | */ |
36 | */ |
37 | 37 | ||
- | 38 | #include "fat_dentry.h" |
|
- | 39 | ||
- | 40 | #define FAT_PAD ' ' |
|
- | 41 | ||
- | 42 | #define FAT_DENTRY_UNUSED 0x00 |
|
- | 43 | #define FAT_DENTRY_E5_ESC 0x05 |
|
- | 44 | #define FAT_DENTRY_DOT 0x2e |
|
- | 45 | #define FAT_DENTRY_ERASED 0xe5 |
|
- | 46 | ||
- | 47 | void dentry_name_canonify(fat_dentry_t *d, char *buf) |
|
- | 48 | { |
|
- | 49 | int i; |
|
- | 50 | ||
- | 51 | for (i = 0; i < FAT_NAME_LEN; i++) { |
|
- | 52 | if (d->name[i] == FAT_PAD) |
|
- | 53 | break; |
|
- | 54 | if (d->name[i] == FAT_DENTRY_E5_ESC) |
|
- | 55 | *buf++ = 0xe5; |
|
- | 56 | else |
|
- | 57 | *buf++ = d->name[i]; |
|
- | 58 | } |
|
- | 59 | if (d->ext[0] != FAT_PAD) |
|
- | 60 | *buf++ = '.'; |
|
- | 61 | for (i = 0; i < FAT_EXT_LEN; i++) { |
|
- | 62 | if (d->ext[i] == FAT_PAD) { |
|
- | 63 | *buf = '\0'; |
|
- | 64 | return; |
|
- | 65 | } |
|
- | 66 | if (d->ext[i] == FAT_DENTRY_E5_ESC) |
|
- | 67 | *buf++ = 0xe5; |
|
- | 68 | else |
|
- | 69 | *buf++ = d->ext[i]; |
|
- | 70 | } |
|
- | 71 | *buf = '\0'; |
|
- | 72 | } |
|
- | 73 | ||
- | 74 | fat_dentry_clsf_t fat_classify_dentry(fat_dentry_t *d) |
|
- | 75 | { |
|
- | 76 | if (d->attr & FAT_ATTR_VOLLABEL) { |
|
- | 77 | /* volume label entry */ |
|
- | 78 | return FAT_DENTRY_SKIP; |
|
- | 79 | } |
|
- | 80 | if (d->name[0] == FAT_DENTRY_ERASED) { |
|
- | 81 | /* not-currently-used entry */ |
|
- | 82 | return FAT_DENTRY_SKIP; |
|
- | 83 | } |
|
- | 84 | if (d->name[0] == FAT_DENTRY_UNUSED) { |
|
- | 85 | /* never used entry */ |
|
- | 86 | return FAT_DENTRY_LAST; |
|
- | 87 | } |
|
- | 88 | if (d->name[0] == FAT_DENTRY_DOT) { |
|
- | 89 | /* |
|
- | 90 | * Most likely '.' or '..'. |
|
- | 91 | * It cannot occur in a regular file name. |
|
- | 92 | */ |
|
- | 93 | return FAT_DENTRY_SKIP; |
|
- | 94 | } |
|
- | 95 | return FAT_DENTRY_VALID; |
|
- | 96 | } |
|
38 | 97 | ||
39 | /** |
98 | /** |
40 | * @} |
99 | * @} |
41 | */ |
100 | */ |