]> git.lyx.org Git - lyx.git/blobdiff - src/support/filename.C
Don't use a global variable for avoiding removal of the system temp dir
[lyx.git] / src / support / filename.C
index c0a01f541df2f9731c217249cbc4c97adc6448f4..8b8a4aee57b8b5d0a0185a8c22f3cf56f338f596 100644 (file)
@@ -14,6 +14,9 @@
 #include "support/filetools.h"
 #include "support/lstrings.h"
 #include "support/os.h"
+#include "support/qstring_helpers.h"
+
+#include <QFile>
 
 #include <boost/assert.hpp>
 
@@ -41,7 +44,8 @@ FileName::~FileName()
 FileName::FileName(string const & abs_filename)
        : name_(abs_filename)
 {
-       BOOST_ASSERT(absolutePath(name_));
+       BOOST_ASSERT(empty() || absolutePath(name_));
+       BOOST_ASSERT(!contains(name_, '\\'));
 }
 
 
@@ -49,6 +53,7 @@ void FileName::set(string const & name)
 {
        name_ = name;
        BOOST_ASSERT(absolutePath(name_));
+       BOOST_ASSERT(!contains(name_, '\\'));
 }
 
 
@@ -60,8 +65,8 @@ void FileName::erase()
 
 string const FileName::toFilesystemEncoding() const
 {
-       // FIXME UNICODE: correct encoding not implemented yet
-       return name_;
+       QByteArray const encoded = QFile::encodeName(toqstr(name_));
+       return string(encoded.begin(), encoded.end());
 }