1 /*
2 Copyright (C) 2017-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4mm.ctr
12 */
13 
14 /**	@file dk4mm.c The dk4mm module.
15 */
16 
17 
18 #include "dk4conf.h"
19 #include <libdk4c/dk4mm.h>
20 #include <libdk4c/dk4statd.h>
21 
22 #if DK4_HAVE_ASSERT_H
23 #ifndef	ASSERT_H_INCLUDED
24 #include <assert.h>
25 #define	ASSERT_H_INCLUDED 1
26 #endif
27 #endif
28 
29 
30 
31 int
dk4makemode_must_rebuild(const dkChar * dn,const dkChar * sn)32 dk4makemode_must_rebuild(const dkChar *dn, const dkChar *sn)
33 {
34 	dk4_stat_t	ds;
35 	dk4_stat_t	ss;
36 	int		 back	= 0;
37 #if	DK4_USE_ASSERT
38   assert(NULL != dn);
39   assert(NULL != sn);
40 #endif
41 	if ((NULL == dn) || (NULL == sn)) {
42 		goto finished;
43 	}
44 	if (0 != dk4stat(&ss, sn, NULL)) {
45 		/* Source file exists. */
46 		back = 1;
47 		if (0 != dk4stat(&ds, dn, NULL)) {
48 			/* Destination file exists. */
49 			if (ds.st_mtime > ss.st_mtime) {
50 				/* Destination file exists and is up to date. */
51 				back = 0;
52 			}
53 		}
54 	}
55 	else {
56 		/* Source file does not exist. */
57 	}
58 
59 	finished:
60 	return back;
61 }
62 
63 
64 /* vim: set ai sw=4 ts=4 : */
65