Timezone classes

Nicolas Goutte nicolasg at snafu.de
Sat Sep 17 21:22:15 BST 2005


On Saturday 17 September 2005 22:17, Nicolas Goutte wrote:
> On Saturday 17 September 2005 21:59, Nicolas Goutte wrote:
> > On Saturday 17 September 2005 20:27, Shaheed wrote:
> > > On Thursday 15 September 2005 19:06, Nicolas Goutte wrote:
> > > > On Thursday 15 September 2005 19:50, David Jarvie wrote:
> > > > (...)
> > > >
> > > > > KTimezones::local() doesn't allow for the possibility of
> > > > > /etc/localtime being a link to a file in /use/share/zoneinfo/ (or
> > > > > wherever). This is quite
> > > >
> > > > If I remember well, the problem about /etc/localtime being a link,
> > > > had been reported immediately in kde-commits (but apparently the code
> > > > was not changed).
> > >
> > > I don't understand either comment (from David or Nicolas). The code in
> > > question is trying to find the name of the file in /use/share/zoneinfo/
> > > (or wherever) with the link or copy of the file that is in
> > > /etc/localtime.
> > >
> > > AFAICS, it should work in both the link or copy case (I am not able to
> > > test right now, but I thought I had done so).
> > >
> > > Does that make more sense? Maybe I need to make the comment there a bit
> > > more verbose...
> >
> > As far as I understand the critic, the wish is to find that the file is a
> > link and to use that link instead of guessing it with some MD5 handling.
>

Sorry...

> Therefore you could use code like (Qt3):
>
> QString zoneInfoFileName;
> QFileInfo fi ( f );
> if ( fi.isSymLink() )
> {
>   const QString ref ( fi.readLink() );
>   QFileInfo fi2 ( ref );
>   if ( ref.exists() && ref.isReadable() )

.. please read:

if ( fi2.exists() && fi2.isReadable() )

>   {
> 	zoneInfoFileName = ref;
>   }
> }
> if ( zoneInfoFileName.isEmpty() )
> {
>    // Find the zoneinfo file by the current method using the size and the
> MD5 ...
>    zoneInfoFileName = somename;
> }
>
> if ( zoneInfoFileName.isEmpty() )
> {
> 	return m_UTC;
> }
> else
> {
> 	// Process zoneInfoName, assuming the file name is not empty.
> }
>
> > Sure the current code should work but it is quite an overhead in such a
> > case, as MD5-ing thousand of files uses much computing power. (Counting
> > quickly&dirty the SuSE 9.0 on my system has 1611 files in the /usr/share/
> > zoneinfo and its subdirectories. However here it is not a link.)
>
> Sorry, i wtote a little too fast. Sure not so many MD5 sums are calcualted
> but as many files a read, having potential drawbacks like purging buffers.

... and here read: "but so many files are read..."

>
> > > Thanks, Shaheed
> >
> > Have a nice day!





More information about the kde-core-devel mailing list