• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

tdeconfigrawbackend.cpp
00001 /*
00002    This file is part of the TDE 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., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "tdeconfigrawbackend.h"
00021 #include "tdeconfigrawbackend.moc"
00022 
00023 #include <unistd.h>
00024 #include <tqfile.h>
00025 
00026 
00027 TDEConfigRawBackEnd::TDEConfigRawBackEnd(TDEConfigBase *_config, int fd)
00028     : TDEConfigINIBackEnd(_config, TQString(), "config", false),
00029       _fd(fd), _stream(0)
00030 {
00031     _file.open(IO_ReadOnly, _fd);
00032 }
00033 
00034 TDEConfigRawBackEnd::~TDEConfigRawBackEnd()
00035 {
00036     if (_stream) fclose(_stream);
00037 }
00038 
00039 bool TDEConfigRawBackEnd::parseConfigFiles()
00040 {
00041     _file.reset();
00042     parseSingleConfigFile(_file);
00043     return true;
00044 }
00045 
00046 void TDEConfigRawBackEnd::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, false, 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 }

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.