MCPcopy Create free account
hub / github.com/apache/nuttx / tmpfs_remove_dirent

Function tmpfs_remove_dirent

fs/tmpfs/fs_tmpfs.c:461–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

459 ****************************************************************************/
460
461static 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

Callers 3

tmpfs_unlinkFunction · 0.85
tmpfs_rmdirFunction · 0.85
tmpfs_renameFunction · 0.85

Calls 3

tmpfs_find_direntFunction · 0.85
fs_heap_freeFunction · 0.85
strlenFunction · 0.50

Tested by

no test coverage detected