From 4ecbf7407c19b59fc136c334f9386c53db453930 Mon Sep 17 00:00:00 2001 From: zecke Date: Tue, 10 Dec 2002 17:01:18 +0000 Subject: get in sync with HEAD again -OPimBase was added to be used as a default struct inside OPimResolver and to work with DSOs -TodoListXML backend now uses mmap and madvise to load data -OContact added/changed rtti -OTodo added changed rtti OPimAccess* added stuff necessary for the Resolver and a 'state'/'hint' on how to load data OPimResolver which resolves uid + services to Records, rtti to QCOPChannels loads arbitary Service backends ( will work with DSOs soon ) -OPimMainWindow added some setDocument scripting possibility and internal marshalling and demarshalling of Records -OPimRecord added loadDataFromm and saveDataTo for marshalling purposes much more :) --- (limited to 'libopie2/opiepim/backend/otodoaccessxml.cpp') diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index b2dfe80..21f93a0 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp @@ -1,3 +1,13 @@ +#include +#include + +#include +#include +#include + +#include + + #include #include @@ -52,20 +62,36 @@ bool OTodoAccessXML::load() { // here the custom XML parser from TT it's GPL // but we want to push OpiePIM... to TT..... - QFile f(m_file ); - if (!f.open(IO_ReadOnly) ) + // mmap part from zecke :) + int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); + struct stat attribut; + if ( fd < 0 ) return false; + + if ( fstat(fd, &attribut ) == -1 ) { + ::close( fd ); return false; + } + void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 ); + if ( map_addr == ( (caddr_t)-1) ) { + ::close(fd ); + return false; + } + /* advise the kernel who we want to read it */ + ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL ); + /* we do not the file any more */ + ::close( fd ); - QByteArray ba = f.readAll(); - f.close(); - char* dt = ba.data(); - int len = ba.size(); + char* dt = (char*)map_addr; + int len = attribut.st_size; int i = 0; char *point; const char* collectionString = "