kconfigrawbackend.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include "kconfigrawbackend.h"
00023 #include "kconfigrawbackend.moc"
00024
00025 #include <unistd.h>
00026 #include <qfile.h>
00027
00028
00029 KConfigRawBackEnd::KConfigRawBackEnd(KConfigBase *_config, int fd)
00030 : KConfigINIBackEnd(_config, QString::null, "config", false),
00031 _fd(fd), _stream(0)
00032 {
00033 _file.open(IO_ReadOnly, _fd);
00034 }
00035
00036 KConfigRawBackEnd::~KConfigRawBackEnd()
00037 {
00038 if (_stream) fclose(_stream);
00039 }
00040
00041 bool KConfigRawBackEnd::parseConfigFiles()
00042 {
00043 _file.reset();
00044 parseSingleConfigFile(_file);
00045 return true;
00046 }
00047
00048 void KConfigRawBackEnd::sync(bool bMerge)
00049 {
00050
00051 if ( !pConfig->isDirty() || pConfig->isReadOnly() ) return;
00052
00053 _file.reset();
00054 KEntryMap aTempMap;
00055 getEntryMap(aTempMap, false, bMerge ? &_file : 0);
00056
00057 if ( _stream==0 ) {
00058 _stream = fdopen(_fd, "w");
00059 if ( _stream==0 ) return;
00060 }
00061 ftruncate(_fd, 0);
00062 writeEntries(_stream, aTempMap);
00063 fflush(_stream);
00064 }
This file is part of the documentation for libkdegames Library Version 3.4.2.