#include "support/FileName.h"
#include "support/FileNameList.h"
-#include "support/convert.h"
#include "support/debug.h"
#include "support/filetools.h"
#include "support/lassert.h"
#include <cerrno>
#include <fcntl.h>
-#if defined(HAVE_MKSTEMP) && ! defined(HAVE_DECL_MKSTEMP)
-extern "C" int mkstemp(char *);
-#endif
-
-#if !defined(HAVE_MKSTEMP) && defined(HAVE_MKTEMP)
-# ifdef HAVE_IO_H
-# include <io.h>
-# endif
-# ifdef HAVE_PROCESS_H
-# include <process.h>
-# endif
-#endif
-
// Three implementations of checksum(), depending on having mmap support or not.
#if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
#define SUM_WITH_MMAP
#endif // SUM_WITH_MMAP
using namespace std;
+using namespace lyx::support;
// OK, this is ugly, but it is the only workaround I found to compile
// with gcc (any version) on a system which uses a non-GNU toolchain.
///
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());
string FileName::realPath() const
{
- return os::real_path(toFilesystemEncoding());
+ return os::real_path(absFilename());
}
string FileName::toFilesystemEncoding() const
{
- // FIXME: This doesn't work on Windows for non ascii file names with Qt < 4.4.
- // Provided that Windows package uses Qt4.4, this isn't a problem.
+ // This doesn't work on Windows for non ascii file names.
QByteArray const encoded = QFile::encodeName(d->fi.absoluteFilePath());
return string(encoded.begin(), encoded.end());
}
+string FileName::toSafeFilesystemEncoding(os::file_access how) const
+{
+ // This will work on Windows for non ascii file names.
+ QString const safe_path =
+ toqstr(os::safe_internal_path(absFilename(), how));
+ QByteArray const encoded = QFile::encodeName(safe_path);
+ return string(encoded.begin(), encoded.end());
+}
+
+
FileName FileName::fromFilesystemEncoding(string const & name)
{
QByteArray const encoded(name.c_str(), name.length());
}
+void FileName::refresh() const
+{
+ d->refresh();
+}
+
+
time_t FileName::lastModified() const
{
// QFileInfo caches information about the file. So, in case this file has
#if QT_VERSION >= 0x999999
// First version of checksum uses Qt4.4 mmap support.
// FIXME: This code is not ready with Qt4.4.2,
- // see http://bugzilla.lyx.org/show_bug.cgi?id=5293
+ // see http://www.lyx.org/trac/ticket/5293
// FIXME: should we check if the MapExtension extension is supported?
// see QAbstractFileEngine::supportsExtension() and
// QAbstractFileEngine::MapExtension)
#else // QT_VERSION
- string const encoded = toFilesystemEncoding();
+ string const encoded = toSafeFilesystemEncoding();
char const * file = encoded.c_str();
#ifdef SUM_WITH_MMAP