+
+// Only used in non Win32 platforms
+static int mymkdir(char const * pathname, unsigned long int mode)
+{
+ // FIXME: why don't we have mode_t in lyx::mkdir prototype ??
+#if HAVE_MKDIR
+# if MKDIR_TAKES_ONE_ARG
+ // MinGW32
+ return ::mkdir(pathname);
+ // FIXME: "Permissions of created directories are ignored on this system."
+# else
+ // POSIX
+ return ::mkdir(pathname, mode_t(mode));
+# endif
+#elif defined(_WIN32)
+ // plain Windows 32
+ return CreateDirectory(pathname, 0) != 0 ? 0 : -1;
+ // FIXME: "Permissions of created directories are ignored on this system."
+#elif HAVE__MKDIR
+ return ::_mkdir(pathname);
+ // FIXME: "Permissions of created directories are ignored on this system."
+#else
+# error "Don't know how to create a directory on this system."
+#endif
+
+}
+
+
+bool FileName::createDirectory(int permission) const
+{
+ LASSERT(!empty(), return false);
+#ifdef Q_OS_WIN32
+ // FIXME: "Permissions of created directories are ignored on this system."
+ return createPath();
+#else
+ return mymkdir(toFilesystemEncoding().c_str(), permission) == 0;
+#endif
+}
+
+
+bool FileName::createPath() const
+{
+ LASSERT(!empty(), return false);
+ LYXERR(Debug::FILES, "creating path '" << *this << "'.");
+ if (isDirectory())
+ return false;
+
+ QDir dir;
+ bool success = dir.mkpath(d->fi.absoluteFilePath());
+ if (!success)
+ LYXERR0("Cannot create path '" << *this << "'!");
+ return success;
+}
+
+
+docstring const FileName::absoluteFilePath() const
+{
+ return qstring_to_ucs4(d->fi.absoluteFilePath());
+}
+
+
+docstring FileName::displayName(int threshold) const
+{
+ return makeDisplayPath(absFileName(), threshold);
+}
+
+
+docstring FileName::fileContents(string const & encoding) const
+{
+ if (!isReadableFile()) {
+ LYXERR0("File '" << *this << "' is not readable!");
+ return docstring();
+ }
+
+ QFile file(d->fi.absoluteFilePath());
+ if (!file.open(QIODevice::ReadOnly)) {
+ LYXERR0("File '" << *this
+ << "' could not be opened in read only mode!");
+ return docstring();