|
|
|
| 26 March 2002 | CompareFileDates() |
| Author | ScriptLogic Corporation |
| Action | Compares the dates of two files. |
| Syntax | CompareFileDates ("file1", ["file2"]) |
| Parameters | |
| Remarks | Similar in function to KiXtart's built-in CompareFileTimes() function, except this UDF compares the date-only portion of the each file's timestamp. Useful when comparing a file on an NTFS partition with a file located on a FAT partition, due to the 2-second rounding issue in Windows. |
| Returns | -3 File2 could not be opened. -2 File1 could not be opened. -1 File1 is older than file2. 0 File1 and file2 have the same date 1 File1 is more recent than file2. |
| Dependencies | SerialDate() |
| Examples |
$rc=CompareFileDates('@Lserver\netlogon\kix32.exe','%WINDIR%\kix32.exe')
IF $rc=1
? 'I need to update the copy of KiX32.exe on your local machine'
ENDIF
|
| Source |
FUNCTION CompareFileTimes ($file1, OPTIONAL $file2)
; Author: ScriptLogic Corporation
; Similar in function to KiXtart's built-in CompareFileTimes()
; function, except this compares the date-only portion of each
; file's timestamp. if $File2 is not specified, $file1 will be
; compared to today's date.
; requires SerialDate() UDF from www.scriptlogic.com/kixtart
DIM $file1sdate, $file2sdate
$file1date=''+GetFileTime($file1)
IF @error ; possible file not found
$comparefiledates=-2
RETURN
ELSE
$file1sdate=serialdate(Substr($file1date,1,10))
ENDIF
IF (''+$file2 = '')
$file2sdate=serialdate(@date)
ELSE
$file2date=''+GetFileTime($file2)
IF @error ; possible file not found
$comparefiledates=-3
RETURN
ELSE
$file2sdate=serialdate(Substr($file2date,1,10))
ENDIF
ENDIF
SELECT
CASE ($file1sdate < $file2sdate)
$comparefiledates=-1
CASE ($file1sdate = $file2sdate)
$comparefiledates=0
CASE ($file1sdate > $file2sdate)
$comparefiledates=1
CASE 1 ; unexpected result
$comparefiledates=-5
ENDSELECT
ENDFUNCTION ; - CompareFileDates -
|
|
|
|