/* --------------------------------------------------------------- */ /* younger -- test whether a stream (file) is newer than another */ /* --------------------------------------------------------------- */ /* */ /* Copyright (c) Mike Cowlishaw, 1990-2012. All rights reserved. */ /* Parts Copyright (c) IBM, 1990-2009. */ /* */ /* Permission to use, copy, modify, and distribute this software */ /* for any non-commercial purpose without fee is hereby granted, */ /* provided that the above copyright notice and this permission */ /* notice appear in all copies, and that notice and the date of */ /* any modifications be added to the software. */ /* */ /* This software is provided "as is". No warranties, whether */ /* express, implied, or statutory, including, but not limited to, */ /* implied warranties of merchantability and fitness for a */ /* particular purpose apply to this software. The author shall */ /* not, in any circumstances, be liable for special, incidental, */ /* or consequential damages, for any reason whatsoever. */ /* */ /* --------------------------------------------------------------- */ /* Argument strings: */ /* stream1 -- first stream name (qualified or not) */ /* stream2 -- second stream name (qualified or not) */ /* */ /* returns 1 if stream1 is younger (has a later date and time) */ /* than stream2, or 0 otherwise; if either stream does not exist */ /* then 0 is returned. */ /* */ /* Times allow 2-seconds slop, to allow for Win9x <--> Win NT etc. */ /* conversions and related problems with FAT16 SD cards. */ /* */ /* --------------------------------------------------------------- */ /* Arg1 is main stream Arg2 is test stream. */ younger: -- procedure parse arg stream1, stream2 t1=SysGetFileDateTime(stream1, "W") if t1='-1' then do --say "Warning: file '"stream1"' not found" return 0 end t2=SysGetFileDateTime(stream2, "W") if t2='-1' then do --say "Warning: file '"stream2"' not found" return 0 end -- say '1:' t1 stream1 -- say '2:' t2 stream2 parse var t1 date1 time1 . parse var t2 date2 time2 . if date1\=date2 then /* date mismatch */ do if date1Win95 conversions */ /* [Occasionally midnighters will over-copy] */ parse var time1 h1':'m1':'s1 parse var time2 h2':'m2':'s2 secs1=h1*3600+m1*60+s1 secs2=h2*3600+m2*60+s2 if secs1<=secs2+2 then return 0 /* not 2 seconds more */ return 1 /* younger */