logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git

del.c (605B)


  1. // Collection of Unix tools, comparable to coreutils
  2. // SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
  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, "remove(%s) error: %s\n", argv[i], strerror(errno));
  17. return 1;
  18. }
  19. }
  20. return 0;
  21. }