#include "support/FileName.h"
#include "support/FileNameList.h"
-#include "support/convert.h"
#include "support/debug.h"
#include "support/filetools.h"
#include "support/lassert.h"
Private(string const & abs_filename) : fi(toqstr(abs_filename))
{
- name = abs_filename;
+ name = fromqstr(fi.absoluteFilePath());
fi.setCaching(fi.exists() ? true : false);
}
///
inline void refresh()
{
-// There seems to be a bug in Qt >= 4.2.0, at least, that causes problems with
+// There seems to be a bug in Qt >= 4.2.0 and < 4.5.0, that causes problems with
// QFileInfo::refresh() on *nix. So we recreate the object in that case.
-// FIXME: When Trolltech fixes the bug, we will have to replace 0x999999 below
-// with the actual working minimum version.
-#if defined(_WIN32) || (QT_VERSION >= 0x999999)
+#if defined(_WIN32) || (QT_VERSION >= 0x040500)
fi.refresh();
#else
fi = QFileInfo(fi.absoluteFilePath());
void FileName::set(string const & name)
{
- d->name = name;
d->fi.setFile(toqstr(name));
+ d->name = fromqstr(d->fi.absoluteFilePath());
//LYXERR(Debug::FILES, "FileName::set(" << name << ')');
LASSERT(empty() || isAbsolute(d->name), /**/);
}
return dirlist;
}
- QDir dir = d->fi.absoluteDir();
+ // If the directory is specified without a trailing '/', absoluteDir()
+ // would return the parent dir, so we must use absoluteFilePath() here.
+ QDir dir = d->fi.absoluteFilePath();
if (!ext.empty()) {
QString filter;
bool operator==(FileName const & lhs, FileName const & rhs)
{
- return lhs.absFilename() == rhs.absFilename();
+ return os::isFilesystemCaseSensitive()
+ ? lhs.absFilename() == rhs.absFilename()
+ : !QString::compare(toqstr(lhs.absFilename()),
+ toqstr(rhs.absFilename()), Qt::CaseInsensitive);
}