| 459 | ****************************************************************************/ |
| 460 | |
| 461 | static int tmpfs_remove_dirent(FAR struct tmpfs_directory_s *tdo, |
| 462 | FAR const char *name) |
| 463 | { |
| 464 | int index; |
| 465 | int last; |
| 466 | |
| 467 | /* Search the list of directory entries for a match */ |
| 468 | |
| 469 | index = tmpfs_find_dirent(tdo, name, strlen(name)); |
| 470 | if (index < 0) |
| 471 | { |
| 472 | return index; |
| 473 | } |
| 474 | |
| 475 | /* Free the object name */ |
| 476 | |
| 477 | if (tdo->tdo_entry[index].tde_name != NULL) |
| 478 | { |
| 479 | fs_heap_free(tdo->tdo_entry[index].tde_name); |
| 480 | } |
| 481 | |
| 482 | /* Remove by replacing this entry with the final directory entry */ |
| 483 | |
| 484 | last = tdo->tdo_nentries - 1; |
| 485 | if (index != last) |
| 486 | { |
| 487 | tdo->tdo_entry[index] = tdo->tdo_entry[last]; |
| 488 | } |
| 489 | |
| 490 | /* And decrement the count of directory entries */ |
| 491 | |
| 492 | tdo->tdo_nentries = last; |
| 493 | return OK; |
| 494 | } |
| 495 | |
| 496 | /**************************************************************************** |
| 497 | * Name: tmpfs_add_dirent |
no test coverage detected