From 440af4f3ebfecd68dabf8ce5524fd3f953e81c71 Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 21 Dec 2020 11:13:51 +0000 Subject: cpt: remove cpt-stat and cpt-readlink, add _stat() and _readlinkf cpt-readlink and cpt-stat were unnecessary additions for mundane tasks. Since they were binaries instead of scripts, they added an extra layer of complexity to the library. These functions are now included inside the package manager library with the names _readlinkf() and _stat(). FossilOrigin-Name: 7e15e2b57ddcb834c4286c8d1ac0a28031ae4f5d39f3c6a99f5b3aa0e9a83d43 --- bin/cpt-stat.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 bin/cpt-stat.c (limited to 'bin/cpt-stat.c') diff --git a/bin/cpt-stat.c b/bin/cpt-stat.c deleted file mode 100644 index 584c2df..0000000 --- a/bin/cpt-stat.c +++ /dev/null @@ -1,41 +0,0 @@ -/* cpt-stat --- a utility for getting the user name of file owner - * See LICENSE for copyright information - * - * The reason this simple tool exists is because 'stat' is not - * portable and ls is not exactly stable enough for scripting. - * This program is for outputting the owner name, and that's it. - */ - -#include -#include -#include -#include - -struct passwd *pw; -struct stat sb; - -int -main (int argc, char *argv[]) -{ - /* Exit if no or multiple arguments are given. */ - if (argc != 2 || strcmp(argv[1], "--help") == 0) { - fprintf(stderr, "Usage: %s [pathname]\n", argv[0]); - return 1; - } - - /* Exit if file stat cannot be obtained. */ - if (lstat(argv[1], &sb) == -1) { - perror(argv[0]); - return 1; - } - - /* Exit if name of the owner cannot be retrieved. */ - if (!getpwuid(sb.st_uid)) { - return 1; - } - - /* Print the user name of file owner. */ - pw = getpwuid(sb.st_uid); - printf("%s\n", pw->pw_name); - return 0; -} -- cgit v1.2.3