summaryrefslogtreecommitdiff
authordrw <drw>2003-03-29 20:32:56 (UTC)
committer drw <drw>2003-03-29 20:32:56 (UTC)
commit4bf2c892cebbf80e825a717b6240d0377a2060ac (patch) (side-by-side diff)
treebac261127383db8c5ae5b1b8b28cf1c7b0fad4ab
parent7c43e678395bbf781195686b34cc596ea72aa512 (diff)
downloadopie-4bf2c892cebbf80e825a717b6240d0377a2060ac.zip
opie-4bf2c892cebbf80e825a717b6240d0377a2060ac.tar.gz
opie-4bf2c892cebbf80e825a717b6240d0377a2060ac.tar.bz2
Better fix for reading feed Packages files.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/server.cpp56
1 files changed, 24 insertions, 32 deletions
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index 64a9c26..9a239a5 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -20,15 +20,10 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <iostream>
-#include <fstream>
-using namespace std;
-
#include "server.h"
#include "datamgr.h"
+#include <qfile.h>
+#include <qtextstream.h>
+
#ifdef QWS
#include <qpe/global.h>
@@ -74,5 +69,5 @@ void Server :: readStatusFile( QList<Destination> &destList )
QString path = dest->getDestinationPath();
if ( path.right( 1 ) != "/" )
- path += "/";
+ path.append( "/" );
if ( path == "/" )
@@ -82,5 +77,6 @@ void Server :: readStatusFile( QList<Destination> &destList )
}
- packageFile = path + "usr/lib/ipkg/status";
+ packageFile = path;
+ packageFile.append( "usr/lib/ipkg/status" );
readPackageFile( 0, false, installingToRoot, &( *dest ) );
}
@@ -89,5 +85,5 @@ void Server :: readStatusFile( QList<Destination> &destList )
if ( !rootRead )
{
- cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
+ //cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
packageFile = "/usr/lib/ipkg/status";
readPackageFile( 0, false, true );
@@ -147,13 +143,13 @@ void Server :: readLocalIpks( Server *local )
void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest )
{
- ifstream in( packageFile );
- if ( !in.is_open() )
+ QFile f( packageFile );
+ if ( !f.open( IO_ReadOnly ) )
return;
+ QTextStream t( &f );
- char line[5001];
- char k[21];
- char v[5001];
+ QString line;
QString key;
QString value;
+ int pos;
if ( clearAll )
@@ -162,19 +158,15 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
bool newPackage = true;
- do
+ while ( !t.eof() )
{
- in.getline( line, 5000 );
- if ( in.eof() )
- continue;
-
- k[0] = '\0';
- v[0] = '\0';
-
- sscanf( line, "%[^:]: %[^\n]", k, v );
+ line = t.readLine();
- key = k;
- value = v;
- key = key.stripWhiteSpace();
- value = value.stripWhiteSpace();
+ pos = line.find( ':', 0 );
+ if ( pos > -1 )
+ key = line.mid( 0, pos ).stripWhiteSpace();
+ else
+ key = QString::null;
+ value = line.mid( pos+1, line.length()-pos ).stripWhiteSpace();
+
if ( key == "Package" && newPackage )
{
@@ -229,11 +221,11 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
DataManager::setAvailableCategories( value );
}
- else if ( key == "" )
+ else if ( key == QString::null )
{
newPackage = true;
}
- } while ( !in.eof() );
+ }
- in.close();
+ f.close();
// build local packages