Article View: borland.public.cppbuilder.nativeapi
Article #14012Re: comparing Dates
From: Bob Gonder
Date: Thu, 04 Sep 2003 20:53
Date: Thu, 04 Sep 2003 20:53
48 lines
2880 bytes
2880 bytes
Luiz Rafael Culik Guimaraes wrote:
>iļæ½m using the FindFirstFile()/FindNextFile() api to get the olddest date of
>an file with an specific directory
>
>static FILETIME GetOldesFile(char * szPath)
>{
> WIN32_FIND_DATA Lastff32;
> HANDLE hLastFind;
>
> FILETIME ftLastWriteTime ={0x99999999,0x9999999}; // <- Set the olddest
>file to an future date(year 3059)
Delete these
>// FILETIME ft,ft1;
>// SYSTEMTIME time,time1;
> char * szf = (char*)malloc(7);
> strcpy(szf,szPath);
> strcat(szf,"*.*");
>
> hLastFind = FindFirstFile( szf,&Lastff32 );
>
> if ( hLastFind != INVALID_HANDLE_VALUE )
> {
???? Set oldest time to the directory time? But only if the first file
in the directory is a subdirectory???
> if (Lastff32.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
> ftLastWriteTime= Lastff32.ftLastAccessTime;
>
> while ( FindNextFile( hLastFind,&Lastff32 )) {
???? If it is a directory? I thought you werre finding oldest file??
> if (Lastff32.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
> {
Luiz, as I quoted from the manual, they suggest you don't use
SYSTEMTIME for comparison, they suggest you convert SYSTEMTIME to
FILETIME.
In your case, you start with FILETIME, so no converion is required!
delete this
>// if( FileTimeToLocalFileTime( &Lastff32.ftLastAccessTime, &ft )&&
>// FileTimeToSystemTime( &ft, &time ) &&
>// FileTimeToLocalFileTime( &ftLastWriteTime, &ft1 ) &&
>// FileTimeToSystemTime( &ft1, &time1 ) )
Simply do this:
if( (LONG_INTEGER)ftLastWriteTime >
(LONG_INTEGER)Lastff32.ftLastAccessTime )
> ftLastWriteTime = Lastff32.ftLastAccessTime;
Technical Details
Message-ID:
<988flvoobe4fh7v2jhkajaglttf6kf5clr@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news-xfer1.atl.newshosting.com!63.218.45.11.MISMATCH!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f574a3e$1@newsgroups.borland.com> <asjelv8fq5h0jkedp42auupaqs62b3c3jd@4ax.com> <3f5764ed@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10cc67,7bb8b0b789f7aaae X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-09-04 13:58:05 PST From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: comparing Dates Date: Thu, 04 Sep 2003 13:53:09 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <988flvoobe4fh7v2jhkajaglttf6kf5clr@4ax.com> References: <3f574a3e$1@newsgroups.borland.com> <asjelv8fq5h0jkedp42auupaqs62b3c3jd@4ax.com> <3f5764ed@newsgroups.borland.com> X-Newsreader: Forte Agent 1.91/32.564 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 67.31.164.4 X-Trace: newsgroups.borland.com 1062708790 67.31.164.4 (4 Sep 2003 13:53:10 -0700) Lines: 50 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news-xfer1.atl.newshosting.com!63.218.45.11.MISMATCH!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail