Changeset 2d0d637 in mainline for uspace/srv/fs/fat/fat_dentry.c
- Timestamp:
- 2011-06-21T18:56:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 61e29a4d
- Parents:
- 9553d7d
- File:
-
- 1 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 /**
Note:
See TracChangeset
for help on using the changeset viewer.