om

om - the most recently modified file in a directory
git clone git://git.larryhynes.net/om
Log | Files | Refs | README | LICENSE

commit 9c4982be1fb94c3cd8eda29253a4b3320d2426ce
parent 0721c39424ae5e56026026e8f1d78829afdb1316
Author: Larry Hynes <larry@larryhynes.com>
Date:   Wed,  5 Jul 2017 10:49:34 +0100

Remove superfluous parens

Diffstat:
om.c | 23+++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/om.c b/om.c @@ -14,25 +14,13 @@ char *dir; char buf[PATH_MAX]; char res[NAME_MAX]; -/* Test if argument can be stat-ed, and is a directory */ -int -isdir() -{ - struct stat st; - if (stat(dir, &st) == 0 && S_ISDIR(st.st_mode)) - return 0; - else { - errx(1, "Could not stat %s", dir); - } -} - /* Check for, and remove, trailing slash on argument */ char *strp() { if (strcmp(dir, "/") != 0) { size_t len = strlen(dir); - if ((dir[len -1] == '/')) + if (dir[len -1] == '/') dir[len -1] = '\0'; } return dir; @@ -50,8 +38,10 @@ om() int c = 0; dirp = opendir(dir); - if (!dirp) - errx(1, "Could not read %s", dir); + if (dirp == NULL) + errx(1, "Could not read directory '%s'", dir); + + strp(); while ((ent = readdir(dirp)) != NULL) { len = strlcpy(buf, dir, sizeof(buf)); @@ -112,9 +102,6 @@ main(int argc, char *argv[]) errx(1, "Usage: %s directory", argv[0]); } - isdir(); - strp(); - om(); prnt(dir, res);