🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17586

Re: How to get timestamp of a directory

#17586
From: David Cameron
Date: Sun, 23 Mar 2003 19:35
74 lines
3990 bytes
"Ed Mulroy [TeamB]" <ed@mulroy.org> wrote in message
news:3e7de3b8@newsgroups.borland.com...
> The Windows API functions FindFirstFile and FindNextFile find files and
> return information about them in a WIN32_FIND_DATA structure which along
> with many other things contains the last write time.  Directories are just
> files and the functions work for them.  Don't forget to call FindClose
when
> you are done with the search.
>
> Depending upon which version of Windows and what file system is on the
disk
> the last modification time and date can be approximate, nearly exact or
not
> given at all.  Don't expect much if using Win95.
>
> .  Ed
>
> > Jarkko Juntunen wrote in message
> > news:Xns9347BC315BB75dzeidzei@207.105.83.65...
> >
> > Need a way to get timestamp (last modification time) of
> > a directory. Can  anyone help?
>
>

Hi Ed,
I agree, FindFirstFile etc is the way to go, but there may be
some special cases.
For instance, if you try FindFirstFile with the name of a root
directory of a drive as the path parameter, the fuction fails
(i.e it returns INVALID_HANDLE_VALUE).
I tried this with "C:\\" and "C:", both returned
INVALID_HANDLE_VALUE.
Do you know of a workaround for this Ed?
Maybe there isn't one, in which case the prog would have
to test the directory name at "input level" to test for this
case.
Maybe it's because the root diretory of a drive is "intrinsic"
or "implied"?

Also the OP specifically used the term "directory" instead
of "folder" but if one wants to deal with the windows
concept of "folders" maybe there is another special case\
complication\problem, specifically "special folders?".
For example "My Documents" passed to FindFirstFile
as the path name results in failure. As you probably know,
if you create several "user profiles" under windows, then
the "My Documents" folder can map to a different directory
depending on the current user.
If no user profiles are used the default "C:\\My Documents"
works OK as it is a directory name as opposed to a folder
name.
I thought maybe there was a shell function that could retieve
the "last modification time" of a folder to cope with the above
cases but I couldn't find one.
Maybe I'm missing something.
Do you know of a shell function which does this?

Also, do you know if the "last modification time" of a directory
(e.g WIN32_FIND_DATA::ftLastWriteTime) is updated in these
circumstances:
  1. A file in that directory is updated.
  2. A new file is created in that directory.
  3. A file is deleted from that directory.
  4. A subdirectory is added to that directory.
  5. A subdirectory is deleted from that directory.
  6. A file is updated\created in a subdiretory of that directory etc.

To the OP, is this the sort of information you need to be
reflected in the "last modification time" of a directory?

TIA,
Dave
Technical Details
Message-ID: <3e7e0c97@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <Xns9347BC315BB75dzeidzei@207.105.83.65> <3e7de3b8@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,ddd5fd2f8652aa3a
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-03-23 22:56:09 PST
Reply-To: "David Cameron" <dave@NO_SPAM.please.ecclehill.freeserve.co.uk>
From: "David Cameron" <dave@NO_SPAM.please.ecclehill.freeserve.co.uk>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <Xns9347BC315BB75dzeidzei@207.105.83.65> <3e7de3b8@newsgroups.borland.com>
Subject: Re: How to get timestamp of a directory
Date: Sun, 23 Mar 2003 19:35:42 -0000
Lines: 76
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 81.76.167.160
Message-ID: <3e7e0c97@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1048448151 81.76.167.160 (23 Mar 2003 11:35:51 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail