libkdegames Library API Documentation

kconfigrawbackend.cpp

00001 /* 00002 This file is part of the KDE games library 00003 Copyright (C) 2003 Nicolas Hadacek <hadacek@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 version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #include "kconfigrawbackend.h" 00021 #include "kconfigrawbackend.moc" 00022 00023 #include <unistd.h> 00024 #include <qfile.h> 00025 00026 00027 KConfigRawBackEnd::KConfigRawBackEnd(KConfigBase *_config, int fd) 00028 : KConfigINIBackEnd(_config, QString::null, "config", false), 00029 _fd(fd), _stream(0) 00030 { 00031 _file.open(IO_ReadOnly, _fd); 00032 } 00033 00034 KConfigRawBackEnd::~KConfigRawBackEnd() 00035 { 00036 if (_stream) fclose(_stream); 00037 } 00038 00039 bool KConfigRawBackEnd::parseConfigFiles() 00040 { 00041 _file.reset(); 00042 parseSingleConfigFile(_file); 00043 return true; 00044 } 00045 00046 void KConfigRawBackEnd::sync(bool bMerge) 00047 { 00048 // write-sync is only necessary if there are dirty entries 00049 if ( !pConfig->isDirty() || pConfig->isReadOnly() ) return; 00050 00051 _file.reset(); 00052 KEntryMap aTempMap; 00053 getEntryMap(aTempMap, true, bMerge ? &_file : 0); 00054 00055 if ( _stream==0 ) { 00056 _stream = fdopen(_fd, "w"); 00057 if ( _stream==0 ) return; 00058 } 00059 ftruncate(_fd, 0); 00060 writeEntries(_stream, aTempMap); 00061 fflush(_stream); 00062 }
KDE Logo
This file is part of the documentation for libkdegames Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Sep 21 12:08:02 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003