[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: kdebase/kcontrol/clock patch to use /etc/localtime as file instead
From: Gustavo Pichorim Boiko <boiko () conectiva ! com ! br>
Date: 2003-12-17 19:43:11
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi
Currently, when timezone is changed, the clock applet makes a
symlink /etc/localtime pointing to the selected timezone.
This is not a good idea because some systems have /usr in another disk (or
partition) and when the system is initialized and the target of symlink is
not mounted yet and then, the system time is set to a wrong value.
IMO is a good idea to copy the new timezone to /etc/localtime (as timeconfig
does).
The attached patch fix this issue. If the patch is ok, I can commit it to cvs.
If anyone knows another way to solve this problem, please tell me.
Thank's
--
Gustavo Pichorim Boiko
--
boiko @ conectiva . com . br
["localtime_as_file.patch" (text/x-diff)]
Index: tzone.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/clock/tzone.cpp,v
retrieving revision 1.25
diff -u -p -r1.25 tzone.cpp
--- tzone.cpp 15 Jun 2003 03:43:21 -0000 1.25
+++ tzone.cpp 17 Dec 2003 19:31:24 -0000
@@ -284,11 +284,34 @@ void Tzone::save()
kdDebug() << "Set time zone " << tz << endl;
- // This is extremely ugly. Who knows the better way?
- unlink( "/etc/localtime" );
- if (symlink( QFile::encodeName(tz), "/etc/localtime" ) != 0)
- KMessageBox::error( 0, i18n("Error setting new Time Zone!"),
- i18n("Timezone Error"));
+ if (!QFile::remove("/etc/localtime"))
+ {
+ //After the KDE 3.2 release, need to add an error message
+ }
+ else
+ {
+ QFile fSelectedTz(tz);
+
+ if (fSelectedTz.open(IO_ReadOnly))
+ {
+ QFile fLocaltime("/etc/localtime");
+
+ if (fLocaltime.open(IO_WriteOnly | IO_Truncate))
+ {
+ QByteArray tzdata = fSelectedTz.readAll();
+
+ fSelectedTz.close();
+ fLocaltime.writeBlock(tzdata);
+ fLocaltime.close();
+ }
+ else
+ {
+ KMessageBox::error( 0, i18n("Error setting new Time Zone!"),
+ i18n("Timezone Error"));
+
+ }
+ }
+ }
QString val = ":" + tz;
#endif // !USE_SOLARIS
[Attachment #8 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic