MCPcopy Create free account
hub / github.com/coreutils/coreutils / rm

Function rm

src/remove.c:600–645  ·  view source on GitHub ↗

Remove FILEs, honoring options specified via X. Return RM_OK if successful. */

Source from the content-addressed store, hash-verified

598/* Remove FILEs, honoring options specified via X.
599 Return RM_OK if successful. */
600enum RM_status
601rm (char *const *file, struct rm_options const *x)
602{
603 enum RM_status rm_status = RM_OK;
604
605 if (*file)
606 {
607 int bit_flags = (FTS_CWDFD
608 | FTS_NOSTAT
609 | FTS_PHYSICAL);
610
611 if (x->one_file_system)
612 bit_flags |= FTS_XDEV;
613
614 FTS *fts = xfts_open (file, bit_flags, NULL);
615
616 while (true)
617 {
618 FTSENT *ent;
619
620 ent = fts_read (fts);
621 if (ent == NULL)
622 {
623 if (errno != 0)
624 {
625 error (0, errno, _("fts_read failed"));
626 rm_status = RM_ERROR;
627 }
628 break;
629 }
630
631 enum RM_status s = rm_fts (fts, ent, x);
632
633 affirm (VALID_STATUS (s));
634 UPDATE_STATUS (rm_status, s);
635 }
636
637 if (fts_close (fts) != 0)
638 {
639 error (0, errno, _("fts_close failed"));
640 rm_status = RM_ERROR;
641 }
642 }
643
644 return rm_status;
645}

Callers 2

do_moveFunction · 0.85
mainFunction · 0.85

Calls 2

xfts_openFunction · 0.85
rm_ftsFunction · 0.85

Tested by

no test coverage detected