kdecore Library API Documentation

ksimpleconfig.cpp

00001 /* This file is part of the KDE libraries 00002 Copyright (c) 1999 Preston Brown <pbrown@kde.org> 00003 Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 // $Id: ksimpleconfig.cpp,v 1.49 2003/09/06 19:06:30 binner Exp $ 00021 00022 #include <config.h> 00023 00024 #ifdef HAVE_SYS_STAT_H 00025 #include <sys/stat.h> 00026 #endif 00027 00028 #include <stdlib.h> 00029 #include <unistd.h> 00030 00031 #include <qfileinfo.h> 00032 00033 #include "kglobal.h" 00034 #include "kstandarddirs.h" 00035 #include "kconfigbackend.h" 00036 00037 #include "ksimpleconfig.h" 00038 00039 KSimpleConfig::KSimpleConfig(const QString &fileName, bool bReadOnly) 00040 : KConfig(QString::fromLatin1(""), bReadOnly, false) 00041 { 00042 // the difference between KConfig and KSimpleConfig is just that 00043 // for KSimpleConfig an absolute filename is guaranteed 00044 if (!fileName.isNull() && fileName[0] != '/') { 00045 backEnd->changeFileName( KGlobal::dirs()-> 00046 saveLocation("config", QString::null, !bReadOnly)+fileName, "config", false); 00047 } else { 00048 backEnd->changeFileName(fileName, "config", false); 00049 } 00050 setReadOnly( bReadOnly ); 00051 reparseConfiguration(); 00052 } 00053 00054 KSimpleConfig::KSimpleConfig(KConfigBackEnd *backEnd, bool bReadOnly) 00055 : KConfig(backEnd, bReadOnly) 00056 {} 00057 00058 KSimpleConfig::~KSimpleConfig() 00059 { 00060 // we need to call the KSimpleConfig version of sync. Relying on the 00061 // regular KConfig sync is bad, because the KSimpleConfig sync has 00062 // different behavior. Syncing here will insure that the sync() call 00063 // in the KConfig destructor doesn't actually do anything. 00064 sync(); 00065 } 00066 00067 void KSimpleConfig::sync() 00068 { 00069 if (isReadOnly()) 00070 return; 00071 backEnd->sync(false); 00072 00073 if (isDirty()) 00074 rollback(); 00075 } 00076 00077 void KSimpleConfig::virtual_hook( int id, void* data ) 00078 { KConfig::virtual_hook( id, data ); } 00079 00080 #include "ksimpleconfig.moc"
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Aug 30 22:53:32 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003