Qt-interest Archive, February 2007
Accessing the file system
Message 1 in thread
I am trying to implement a class for atomic file system writes.
I need to find a way to replace the old version with a tenporary file
I creates,
when closing the data stream. Are there any routines for this in the
Qt Library?
Code follows, to show what I've written so far.
header: QTNAtomicDataStream.h
#ifndef QTTNATOMICDATASTREAM_H
#define QTTNATOMICDATASTREAM_H
#include <QDataStream>
class QTNAtomicDataStream: protected QDataStream
{
public:
QTNAtomicDataStream(const QString & pathName);
~QTNAtomicDataStream();
QDataStream & getStream();
void close();
protected:
bool exists;
QString canonicalPath;
QString tempSavePath;
QFile * f;
};
#endif
QTNAtomicDataStream.cpp:
#include "QTNAtomicDataStream.h"
QTNAtomicDataStream::QTNAtomicDataStream(const QString &
pathName):QDataStream()
{
QFileInfo fileInfo(pathName);
fileInfo.makeAbsolute();
canonicalPath = fileInfo.canonicalPath();
if (fileInfo.exists()) {
exists = true;
QDir dir = fileInfo.absoluteDir();
bool tmpres = dir.mkdir(QString(".tmp"));// Is it considered an
error for the dir to exist?
tempSavePath = dir.absoluteFilePath(QString(".tmp/") +
fileInfo.fileName());
f = new QFile(tempSavePath);
} else {
exists = false;
f = new QFile(canonicalPath);
}
f->open(QIODevice::WriteOnly);
setDevice(f);
}
QTNAtomicDataStream::~QTNAtomicDataStream()
{
delete f;
}
void QTNAtomicDataStream::close()
{
QDataStream::close();
if (! exists) return;
/* What should I do here, to move the temporary file atop the old
version? */
}
QDataStream & QTNAtomicDataStream::getStream()
{
return * this;
}
------------------------------------------------------
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
tommy.nordgren@xxxxxxxxx
--
[ signature omitted ]
Message 2 in thread
I have an application which runs well on one machine. But when I copy
the exe and execute on another machine (same Qt4.1.1 installation)
it pops a message titled: "Entry Point Not Found"
"The procedure entry point ?append@?$QVector@VQPointF …
could not be located in the dynamic link library QtGuid.dll"
Does anyone know where the problem comes from?
Thanks,
Lingfa
--
[ signature omitted ]
Message 3 in thread
If it really is an identical Qt Version, it might be that both libs
were compiled with different compilers. Unfortunately C++ libs
are a little susceptible to such problems.
> Does anyone know where the problem comes from?
Nope, wild guess, not knowing. :-)
Guido
--
[ signature omitted ]
Message 4 in thread
Guido Seifert schrieb:
> If it really is an identical Qt Version, it might be that both libs
> were compiled with different compilers. Unfortunately C++ libs
> are a little susceptible to such problems.
Also use Dependency Walker and double check on both systems that the
expected Qt DLLs are taken. Maybe you have an older Qt version installed
on the test machine (where you experience this "Entry Point Not Found"
message) which is taken instead of the expected Qt 4.1.1 one?
And apart from different compilers being used for compiling the Qt DLLs
maybe different compiler switches where used, too (with/without STL
support etc.)?
But I assume you have copied your *.exe together with the Qt DLLs in
question, so they should be 1:1 on both systems, no?
As a simple test: copy all required Qt DLLs into the application
directory (see again Dependency Walker which ones you require) and copy
everything onto the target machine (double-checking again with the
Dependency Walker that the Qt DLLs from the application directory are
taken - Windows looks there first for DLLs, but you never know
(especially when it comes to "manifested DLLs" such as the VS2005
runtime DLLs, see other thread "VS2005/Qt plugins/VC80 DLL installation
problems & solutions (for JPEG plugin and friends)" ;)
>> Does anyone know where the problem comes from?
>
> Nope, wild guess, not knowing. :-)
Just another wild guess...
Cheers, Oliver
--
[ signature omitted ]