Add a "cnewer" primary which evaluates true if a file has a more recent
ctime than its argument. From kre in PR bin/14802; originally suggested name was "updated" but renamed due to GNU find(1) being prior art for this functionality.
This commit is contained in:
parent
e3ed0e40da
commit
e7566d6000
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: extern.h,v 1.14 2001/09/21 07:11:33 enami Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.15 2001/12/01 14:10:04 kleink Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
|
@ -53,6 +53,7 @@ int queryuser __P((char **));
|
|||
PLAN *c_amin __P((char ***, int));
|
||||
PLAN *c_atime __P((char ***, int));
|
||||
PLAN *c_cmin __P((char ***, int));
|
||||
PLAN *c_cnewer __P((char ***, int));
|
||||
PLAN *c_ctime __P((char ***, int));
|
||||
PLAN *c_depth __P((char ***, int));
|
||||
PLAN *c_exec __P((char ***, int));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: find.1,v 1.28 2001/07/06 18:12:02 abs Exp $
|
||||
.\" $NetBSD: find.1,v 1.29 2001/12/01 14:10:04 kleink Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -36,7 +36,7 @@
|
|||
.\"
|
||||
.\" from: @(#)find.1 8.7 (Berkeley) 5/9/95
|
||||
.\"
|
||||
.Dd January 4, 1999
|
||||
.Dd December 1, 2001
|
||||
.Dt FIND 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -180,6 +180,9 @@ information and the time
|
|||
was started, rounded up to the next full minute, is
|
||||
.Ar n
|
||||
minutes.
|
||||
.It Ic -cnewer Ar file
|
||||
True if the current file has a more recent last change time than
|
||||
.Ar file .
|
||||
.It Ic -ctime Ar n
|
||||
True if the difference between the time of last change of file status
|
||||
information and the time
|
||||
|
@ -529,6 +532,7 @@ standard.
|
|||
The options and the
|
||||
.Ic -amin ,
|
||||
.Ic -cmin ,
|
||||
.Ic -cnewer ,
|
||||
.Ic -follow ,
|
||||
.Ic -fstype ,
|
||||
.Ic -inum ,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: find.h,v 1.12 1999/07/20 01:28:41 cgd Exp $ */
|
||||
/* $NetBSD: find.h,v 1.13 2001/12/01 14:10:04 kleink Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -43,8 +43,8 @@
|
|||
/* node type */
|
||||
enum ntype {
|
||||
N_AND = 1, /* must start > 0 */
|
||||
N_AMIN, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CTIME, N_DEPTH, N_EXEC,
|
||||
N_EXPR, N_FLAGS, N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_IREGEX,
|
||||
N_AMIN, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CNEWER, N_CTIME, N_DEPTH,
|
||||
N_EXEC, N_EXPR, N_FLAGS, N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_IREGEX,
|
||||
N_LINKS, N_LS,
|
||||
N_MMIN, N_MTIME, N_NAME, N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK,
|
||||
N_OPENPAREN, N_OR, N_PATH, N_PERM, N_PRINT, N_PRINT0, N_PRINTX,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: function.c,v 1.38 2001/09/21 07:11:33 enami Exp $ */
|
||||
/* $NetBSD: function.c,v 1.39 2001/12/01 14:10:04 kleink Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -41,7 +41,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: function.c,v 1.38 2001/09/21 07:11:33 enami Exp $");
|
||||
__RCSID("$NetBSD: function.c,v 1.39 2001/12/01 14:10:04 kleink Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -84,6 +84,7 @@ static int64_t find_parsenum __P((PLAN *, char *, char *, char *));
|
|||
int f_amin __P((PLAN *, FTSENT *));
|
||||
int f_atime __P((PLAN *, FTSENT *));
|
||||
int f_cmin __P((PLAN *, FTSENT *));
|
||||
int f_cnewer __P((PLAN *, FTSENT *));
|
||||
int f_ctime __P((PLAN *, FTSENT *));
|
||||
int f_exec __P((PLAN *, FTSENT *));
|
||||
int f_flags __P((PLAN *, FTSENT *));
|
||||
|
@ -263,6 +264,42 @@ c_cmin(argvp, isok)
|
|||
TIME_CORRECT(new, N_CMIN);
|
||||
return (new);
|
||||
}
|
||||
|
||||
/*
|
||||
* -cnewer file functions --
|
||||
*
|
||||
* True if the current file has been changed more recently
|
||||
* then the changed time of the file named by the pathname
|
||||
* file.
|
||||
*/
|
||||
int
|
||||
f_cnewer(plan, entry)
|
||||
PLAN *plan;
|
||||
FTSENT *entry;
|
||||
{
|
||||
|
||||
return (entry->fts_statp->st_ctime > plan->t_data);
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_cnewer(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *filename = **argvp;
|
||||
PLAN *new;
|
||||
struct stat sb;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
if (stat(filename, &sb))
|
||||
err(1, "%s", filename);
|
||||
new = palloc(N_CNEWER, f_cnewer);
|
||||
new->t_data = sb.st_ctime;
|
||||
return (new);
|
||||
}
|
||||
|
||||
/*
|
||||
* -ctime n functions --
|
||||
*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: option.c,v 1.15 2000/10/18 08:58:11 jdolecek Exp $ */
|
||||
/* $NetBSD: option.c,v 1.16 2001/12/01 14:10:04 kleink Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
|
@ -41,7 +41,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "from: @(#)option.c 8.2 (Berkeley) 4/16/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: option.c,v 1.15 2000/10/18 08:58:11 jdolecek Exp $");
|
||||
__RCSID("$NetBSD: option.c,v 1.16 2001/12/01 14:10:04 kleink Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -69,6 +69,7 @@ static OPTION const options[] = {
|
|||
{ "-and", N_AND, c_null, 0 },
|
||||
{ "-atime", N_ATIME, c_atime, 1 },
|
||||
{ "-cmin", N_CMIN, c_cmin, 1 },
|
||||
{ "-cnewer", N_CNEWER, c_cnewer, 1 },
|
||||
{ "-ctime", N_CTIME, c_ctime, 1 },
|
||||
{ "-depth", N_DEPTH, c_depth, 0 },
|
||||
{ "-exec", N_EXEC, c_exec, 1 },
|
||||
|
|
Loading…
Reference in New Issue