dirname.c 518 B

12345678910111213141516171819202122
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2018 K. Lange
  5. *
  6. * dirname - print directory name from path string
  7. */
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <libgen.h>
  11. int main(int argc, char * argv[]) {
  12. if (argc < 2) {
  13. fprintf(stderr, "%s: expected argument\n", argv[0]);
  14. return 1;
  15. }
  16. char * c = dirname(argv[1]);
  17. fprintf(stdout, "%s\n", c);
  18. return 0;
  19. }