Changeset 2d0d637 in mainline
- Timestamp:
- 2011-06-21T18:56:31Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 61e29a4d
- Parents:
- 9553d7d
- Location:
- uspace/srv/fs/fat
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_dentry.c
r9553d7d r2d0d637 394 394 } 395 395 396 bool fat_lfn_valid_char(uint16_t c) 397 { 398 char valid[] = {"_.$%\'-@~!(){}^#&"}; 399 size_t idx=0; 400 401 if (c > 0xff) return false; 402 if (isdigit(c) || (isalpha(c) && isupper(c))) 403 return true; 404 while(valid[idx]!=0) 405 if (c == valid[idx++]) 406 return true; 407 408 return false; 409 } 410 411 bool fat_lfn_valid_str(const uint16_t *str) 412 { 413 uint16_t c; 414 size_t idx=0; 415 if (str[idx] == 0 || str[idx] == '.') 416 return false; 417 while ((c=str[idx++]) != 0) { 418 if (!fat_lfn_valid_char(c)) 419 return false; 420 } 421 return true; 422 } 423 424 /** Get number of characters in a wide string. 425 * 426 * @param str NULL-terminated wide string. 427 * 428 * @return Number of characters in @a str. 429 * 430 */ 431 size_t utf16_length(const uint16_t *wstr) 432 { 433 size_t len = 0; 434 435 while (*wstr++ != 0) 436 len++; 437 return len; 438 } 439 440 bool fat_dentry_is_sfn(const uint16_t *str) 441 { 442 /* 1. Length <= 11 characters */ 443 if (utf16_length(str) > (FAT_NAME_LEN + FAT_EXT_LEN)) 444 return false; 445 /* 446 * 2. All characters in string should be ASCII 447 * 3. All letters must be uppercase 448 * 4. String should not contain invalid characters 449 */ 450 if (!fat_lfn_valid_str(str)) 451 return false; 452 453 return true; 454 } 455 396 456 397 457 /** -
uspace/srv/fs/fat/fat_dentry.h
r9553d7d r2d0d637 140 140 extern size_t fat_lfn_copy_part(const uint16_t *, size_t, uint16_t *, size_t *); 141 141 extern size_t fat_lfn_copy_entry(const fat_dentry_t *, uint16_t *, size_t *); 142 142 143 extern int utf16_to_str(char *, size_t, const uint16_t *); 143 144 extern int str_to_utf16(uint16_t *, size_t, const char *); 145 extern bool fat_lfn_valid_char(uint16_t); 146 extern bool fat_lfn_valid_str(const uint16_t *); 147 extern size_t utf16_length(const uint16_t *); 148 extern bool fat_dentry_is_sfn(const uint16_t *); 144 149 145 150 -
uspace/srv/fs/fat/fat_directory.c
r9553d7d r2d0d637 254 254 } 255 255 256 int fat_directory_write(fat_directory_t *di, char *name, fat_dentry_t *de) 257 { 258 /* TODO: create LFN records if necessarry and create SFN record */ 259 return EOK; 260 } 261 262 256 263 257 264 /** -
uspace/srv/fs/fat/fat_directory.h
r9553d7d r2d0d637 67 67 68 68 extern int fat_directory_read(fat_directory_t *, char *, fat_dentry_t **); 69 extern int fat_directory_write(fat_directory_t *, char *, fat_dentry_t *); 69 70 extern int fat_directory_erase(fat_directory_t *); 70 71
Note:
See TracChangeset
for help on using the changeset viewer.