om

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

commit 1d5faf23407b5694d2f5694cc2ab7526e99680ee
parent 246e0b61585c93b0e8a9901dbd9ad3c7a3d515b7
Author: Larry Hynes <larry@larryhynes.com>
Date:   Mon, 26 Jun 2017 17:13:33 +0100

Don't use dir twice
- rename second use of dir, to directory
- No, I don't know what I was thinking

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

diff --git a/om.c b/om.c @@ -28,21 +28,21 @@ char buf[PATH_MAX]; char rcnt[PATH_MAX]; void -om(const char* dir, char* rcnt) +om(const char* directory, char* rcnt) { DIR *dirp; struct dirent *ent; struct stat sb; time_t mtime = 0; - dirp = opendir(dir); + dirp = opendir(directory); if (dirp != NULL) { while ((ent = readdir(dirp)) != NULL) { if (ent->d_type == DT_REG) { - snprintf(buf, PATH_MAX, "%s/%s", dir, ent->d_name); + snprintf(buf, PATH_MAX, "%s/%s", directory, ent->d_name); stat(buf, &sb); if (sb.st_mtime > mtime) { - snprintf(rcnt, PATH_MAX, "%s/%s", dir, ent->d_name ); + snprintf(rcnt, PATH_MAX, "%s/%s", directory, ent->d_name ); mtime = sb.st_mtime; } } @@ -51,7 +51,7 @@ om(const char* dir, char* rcnt) closedir(dirp); } else { - errx(1, "Could not open %s", dir); + errx(1, "Could not open %s", directory); } }