Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / bsd / am-utils / dist / m4 / copy-if-newbig
blob3438c526356290fdf6a94f400fc581c9b48ff361
1 #!/usr/bin/perl -w
2 # copy a file if it is both newer and bigger in size
3 # if copying, first rename older file to .orig
5 $src = $ARGV[0];
6 $dst = $ARGV[1];
7 # dev,ino,mode,nlink,uid,gid,rdev,size,atime,mtime,ctime,blksize,blocks
8 @srcstat = stat($src);
9 @dststat = stat($dst);
11 $srcsize = $srcstat[7];
12 $srcmtime = $srcstat[9];
13 $dstsize = $dststat[7];
14 $dstmtime = $dststat[9];
16 # copy if src file is bigger and newer
17 if ($srcsize > $dstsize && $srcmtime > $dstmtime) {
18 print "mv -f $dst $dst.orig\n";
19 system("mv -f $dst $dst.orig");
20 print "cp -p $src $dst\n";
21 system("cp -p $src $dst");
22 die "cp command failed" if ($? != 0);
24 # make sure dst file has newer timestamp
25 if ($srcmtime > $dstmtime) {
26 print "touch $dst\n";
27 system("touch $dst");
29 exit(0);