logo

utils-extra

Collection of extra tools for Unixes

del.c (589B)


  1. // utils-extra: Collection of extra tools for Unixes
  2. // SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: MPL-2.0
  4. #define _POSIX_C_SOURCE 200809L
  5. #include <errno.h> /* errno */
  6. #include <stdio.h> /* remove() */
  7. #include <string.h> /* strerror() */
  8. int
  9. main(int argc, char *argv[])
  10. {
  11. for(int i = 1; i < argc; i++)
  12. {
  13. if(remove(argv[i]) < 0)
  14. {
  15. // TODO: interact on write protection to force deletion
  16. fprintf(stderr, "del: remove(%s) error: %s\n", argv[i], strerror(errno));
  17. return 1;
  18. }
  19. }
  20. return 0;
  21. }