summaryrefslogtreecommitdiff
path: root/library/config.cpp
authoreilers <eilers>2003-08-08 14:45:49 (UTC)
committer eilers <eilers>2003-08-08 14:45:49 (UTC)
commit14d394e6c107b037a09a31a92605034fe50f7813 (patch) (side-by-side diff)
tree800699cf4dc9681c3eb023340634dd6a15fd04c8 /library/config.cpp
parentdbc6ea35f5535a1f69deb7ebbafc0f721721dbf2 (diff)
downloadopie-14d394e6c107b037a09a31a92605034fe50f7813.zip
opie-14d394e6c107b037a09a31a92605034fe50f7813.tar.gz
opie-14d394e6c107b037a09a31a92605034fe50f7813.tar.bz2
Merged branches from BRANCH_1_0
Diffstat (limited to 'library/config.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/config.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/library/config.cpp b/library/config.cpp
index b47c620..b28c771 100644
--- a/library/config.cpp
+++ b/library/config.cpp
@@ -463,9 +463,9 @@ void Config::write( const QString &fn )
git = groups.end();
return;
}
-
+
QString str;
- QCString cstr;
+ QCString cstr;
QMap< QString, ConfigGroup >::Iterator g_it = groups.begin();
for ( ; g_it != groups.end(); ++g_it ) {
@@ -475,7 +475,7 @@ void Config::write( const QString &fn )
str += e_it.key() + " = " + *e_it + "\n";
}
cstr = str.utf8();
-
+
int total_length;
total_length = f.writeBlock( cstr.data(), cstr.length() );
if ( total_length != int(cstr.length()) ) {
@@ -485,14 +485,14 @@ void Config::write( const QString &fn )
QFile::remove( strNewFile );
return;
}
-
+
f.close();
// now rename the file...
if ( rename( strNewFile, filename ) < 0 ) {
- qWarning( "problem renaming the file %s to %s", strNewFile.latin1(),
+ qWarning( "problem renaming the file %s to %s", strNewFile.latin1(),
filename.latin1() );
QFile::remove( strNewFile );
- }
+ }
}
/*!
@@ -521,6 +521,16 @@ void Config::read()
return;
}
+
+ // hack to avoid problems if big files are passed to test
+ // if they are valid configs ( like passing a mp3 ... )
+ // I just hope that there are no conf files > 100000 byte
+ // not the best solution, find something else later
+ if ( f.size() > 100000 ) {
+ return;
+ }
+
+
QTextStream s( &f );
#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
// The below should work, but doesn't in Qt 2.3.0
@@ -546,10 +556,10 @@ void Config::read()
bool Config::parse( const QString &l )
{
QString line = l.stripWhiteSpace();
-
+
if ( line [0] == QChar ( '#' ))
return true; // ignore comments
-
+
if ( line[ 0 ] == QChar( '[' ) ) {
QString gname = line;
gname = gname.remove( 0, 1 );