Article View: borland.public.cppbuilder.nativeapi
Article #15539R: File Last Write Time
From: Enrico B.
Date: Tue, 24 Jun 2003 15:23
Date: Tue, 24 Jun 2003 15:23
52 lines
2410 bytes
2410 bytes
Thank you *very* much!
Henry
Giuliano <gcardinali@remove.adhoc.net> wrote in message
sg9efvog0r2vcvi87adq64d9ov0tbu8mjp@4ax.com...
> On Mon, 23 Jun 2003 17:11:50 +0200, "Enrico B." <eangelo@libero.it> wrote:
>
> >Hi to All!
> >Can somebody provide me with a piece of code to be used to retrieve a
file
> >last modification time? I tried "stat" but on Windows O.S. that function
> >only returns the last access time. I also tried GetFileTime but something
is
> >wrong with it.
> >Thanks in advance
> >Henry
> >
> >
>
> TDateTime __fastcall GetLastWriteTime( AnsiString File )
> {
> WIN32_FIND_DATA FindFileData;
>
> HANDLE HFile = FindFirstFile( File.c_str(), &FindFileData );
> if ( HFile == INVALID_HANDLE_VALUE )
> RaiseLastOSError();
>
> class X {
> public:
> X( HANDLE hFile ) : hFile_( hFile ) {}
> ~X() throw() { FindClose( hFile_ ); }
> private:
> const HANDLE hFile_;
> }
> Finalize( HFile );
>
> FILETIME LT;
>
> if ( !FileTimeToLocalFileTime( &FindFileData.ftLastWriteTime, < ) )
> RaiseLastOSError();
>
> SYSTEMTIME ST;
>
> if ( !FileTimeToSystemTime( <, &ST ) )
> RaiseLastOSError();
>
> return TDateTime( ST.wYear, ST.wMonth, ST.wDay ) +
> TDateTime( ST.wHour, ST.wMinute, ST.wSecond,
ST.wMilliseconds );
> }
>
Technical Details
Message-ID:
<3ef868df@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ef71448@newsgroups.borland.com> <sg9efvog0r2vcvi87adq64d9ov0tbu8mjp@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,df83c650f00e2702 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-24 08:34:58 PST Reply-To: "Enrico B." <eangelo@libero.it> From: "Enrico B." <eangelo@libero.it> Newsgroups: borland.public.cppbuilder.nativeapi References: <3ef71448@newsgroups.borland.com> <sg9efvog0r2vcvi87adq64d9ov0tbu8mjp@4ax.com> Subject: R: File Last Write Time Date: Tue, 24 Jun 2003 17:23:48 +0200 Lines: 54 Organization: Idinet X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 NNTP-Posting-Host: 212.38.43.33 Message-ID: <3ef868df@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1056467167 212.38.43.33 (24 Jun 2003 08:06:07 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail