unlink.c 657 B

123456789101112131415161718192021222324
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. * Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com>
  4. */
  5. #include <unistd.h>
  6. #include <stdio.h>
  7. #include <errno.h>
  8. #define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */
  9. #define REQ_ERRPRINT /* Require errprint() from ../common/common.h */
  10. #define DESCRIPTION "Call the unlink() function."
  11. #define OPERANDS "file"
  12. #include "../common/common.h"
  13. int main(int argc, char *const argv[]) {
  14. if (argc != 2) {
  15. print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION);
  16. return 1;
  17. }
  18. unlink(argv[1]);
  19. if (errno) return errprint(argv[0], argv[1], errno);
  20. return 0;
  21. }