In my simple program, it shows the last write times compare exactly
equal according to CompareFileTime. However, COPY /UF continues to
copy the file. In fact, when I force all three times to be exactly the
same, COPY /UF continues to copy the file.
I don't see how CompareFileTime can be used to do the /UF function of
"more than 2 seconds newer" directly. You must do some interesting
manipulation instead.
#include "windows.h"
#include "stdio.h"
int main(int argc, char * argv[])
{
HANDLE hFile1, hFile2;
FILETIME ftFileC1, ftFileA1, ftFileW1;
FILETIME ftFileC2, ftFileA2, ftFileW2;
hFile1 = CreateFile(argv[1], GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hFile1 == INVALID_HANDLE_VALUE) abort();
hFile2 = CreateFile(argv[2], GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hFile2 == INVALID_HANDLE_VALUE) abort();
if (!GetFileTime(hFile1, &ftFileC1, &ftFileA1, &ftFileW1)) abort();
if (!GetFileTime(hFile2, &ftFileC2, &ftFileA2, &ftFileW2)) abort();
printf("C=%d A=%d W=%d\n",
CompareFileTime(&ftFileC1, &ftFileC2),
CompareFileTime(&ftFileA1, &ftFileA2),
CompareFileTime(&ftFileW1, &ftFileW2));
}
On Tue, Jun 2, 2009 at 4:52 PM, rconn <> wrote:
> Jim Cook wrote:
>
>
> ---Quote---
>> ---Quote---
>>>> Assuming you don't have an alias for COPY, this would have to be a
>>>> Windows issue on your system. *(Both the time comparison and copy are
>>>> done by Windows APIs.)
>> ---End Quote---
>> Rex:
>>
>> What are you using for the time comparison?
>> Are you using CopyFile or CopyFileEx for the file copy?
> ---End Quote---
> CopyFileEx for the file copy, and CompareFileTime to compare the last
> write times.
>
> Rex Conn
> JP Software
>
>
>
>
>
--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.