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

libtdegames

  • libtdegames
  • highscore
tdeconfigrawbackend.cpp
1 /*
2  This file is part of the TDE games library
3  Copyright (C) 2003 Nicolas Hadacek <hadacek@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "tdeconfigrawbackend.h"
21 #include "tdeconfigrawbackend.moc"
22 
23 #include <unistd.h>
24 #include <tqfile.h>
25 
26 
27 TDEConfigRawBackEnd::TDEConfigRawBackEnd(TDEConfigBase *_config, int fd)
28  : TDEConfigINIBackEnd(_config, TQString(), "config", false),
29  _fd(fd), _stream(0)
30 {
31  _file.open(IO_ReadOnly, _fd);
32 }
33 
34 TDEConfigRawBackEnd::~TDEConfigRawBackEnd()
35 {
36  if (_stream) fclose(_stream);
37 }
38 
39 bool TDEConfigRawBackEnd::parseConfigFiles()
40 {
41  _file.reset();
42  parseSingleConfigFile(_file);
43  return true;
44 }
45 
46 void TDEConfigRawBackEnd::sync(bool bMerge)
47 {
48  // write-sync is only necessary if there are dirty entries
49  if ( !pConfig->isDirty() || pConfig->isReadOnly() ) return;
50 
51  _file.reset();
52  KEntryMap aTempMap;
53  getEntryMap(aTempMap, false, bMerge ? &_file : 0);
54 
55  if ( _stream==0 ) {
56  _stream = fdopen(_fd, "w");
57  if ( _stream==0 ) return;
58  }
59  ftruncate(_fd, 0);
60  writeEntries(_stream, aTempMap);
61  fflush(_stream);
62 }

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.8.13
This website is maintained by Timothy Pearson.