kconfigrawbackend.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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 }
|