diff options
| author | 2012-12-22 02:33:15 +0000 | |
|---|---|---|
| committer | 2012-12-22 02:33:15 +0000 | |
| commit | 6cb55b018c07117b097ed1f7e5597c12ab7ffdde (patch) | |
| tree | b68ec47e87c1dde62cc18c16a473d4e312ea7066 /src/modules/file | |
| parent | Fix a typo introduced by the last commit (diff) | |
| download | KVIrc-6cb55b018c07117b097ed1f7e5597c12ab7ffdde.tar.gz KVIrc-6cb55b018c07117b097ed1f7e5597c12ab7ffdde.tar.bz2 KVIrc-6cb55b018c07117b097ed1f7e5597c12ab7ffdde.zip | |
Fix $file.readLines
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@6299 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/file')
| -rw-r--r-- | src/modules/file/libkvifile.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/modules/file/libkvifile.cpp b/src/modules/file/libkvifile.cpp index b8bf0cbb7..e2e5735a2 100644 --- a/src/modules/file/libkvifile.cpp +++ b/src/modules/file/libkvifile.cpp @@ -992,6 +992,7 @@ static bool file_kvs_fnc_readLines(KviKvsModuleFunctionCall * c) KviFileUtils::adjustFilePath(szName); QFile f(szName); + if(!f.open(QIODevice::ReadOnly)) { c->warning(__tr2qs("Can't open the file '%Q' for reading"),&szName); @@ -1019,13 +1020,22 @@ static bool file_kvs_fnc_readLines(KviKvsModuleFunctionCall * c) if(iCount > 0) { - for(;(iCount > 0 && !stream.atEnd()); iCount--) - pArray->set(iIndex,new KviKvsVariant(stream.readLine())); + while(iCount > 0) + { + QString szLine = stream.readLine(); + if(szLine.isNull()) + break; // EOF (atEnd() is unreliable on files in /proc) + pArray->set(iIndex,new KviKvsVariant(szLine)); iIndex++; + iCount--; + } } else { - while(!stream.atEnd()) + for(;;) { - pArray->set(iIndex,new KviKvsVariant(stream.readLine())); + QString szLine = stream.readLine(); + if(szLine.isNull()) + break; // EOF (atEnd() is unreliable on files in /proc) + pArray->set(iIndex,new KviKvsVariant(szLine)); iIndex++; } } |
