]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
Updates from Bennett and myself.
[lyx.git] / src / buffer.C
index 22eb727982f87bf98ff8cf097bc64165f2beacef..992d61a846c9c464313472fc06a10b4b8b403b53 100644 (file)
@@ -101,6 +101,7 @@ using support::changeExtension;
 using support::cmd_ret;
 using support::createBufferTmpDir;
 using support::destroyDir;
+using support::FileName;
 using support::getFormatFromContents;
 using support::isDirWriteable;
 using support::libFileSearch;
@@ -143,7 +144,7 @@ using std::string;
 
 namespace {
 
-int const LYX_FORMAT = 254;
+int const LYX_FORMAT = 255;
 
 } // namespace anon
 
@@ -460,7 +461,7 @@ int Buffer::readHeader(LyXLex & lex)
                                docstring const s = bformat(_("Unknown token: "
                                                                        "%1$s %2$s\n"),
                                                         from_utf8(token),
-                                                        from_utf8(lex.getString()));
+                                                        lex.getDocString());
                                errorList.push_back(ErrorItem(_("Document header error"),
                                        s, -1, 0, 0));
                        }
@@ -571,7 +572,8 @@ void Buffer::insertStringAsLines(ParagraphList & pars,
 bool Buffer::readFile(string const & filename)
 {
        // Check if the file is compressed.
-       string const format = getFormatFromContents(filename);
+       FileName const name(makeAbsPath(filename));
+       string const format = getFormatFromContents(name);
        if (format == "gzip" || format == "zip" || format == "compress") {
                params().compressed = true;
        }
@@ -579,7 +581,7 @@ bool Buffer::readFile(string const & filename)
        // remove dummy empty par
        paragraphs().clear();
        LyXLex lex(0, 0);
-       lex.setFile(filename);
+       lex.setFile(name);
        if (!readFile(lex, filename))
                return false;
 
@@ -655,7 +657,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
                                              from_utf8(filename)));
                        return false;
                }
-               string const lyx2lyx = libFileSearch("lyx2lyx", "lyx2lyx");
+               FileName const lyx2lyx = libFileSearch("lyx2lyx", "lyx2lyx");
                if (lyx2lyx.empty()) {
                        Alert::error(_("Conversion script not found"),
                                     bformat(_("%1$s is from an earlier"
@@ -666,7 +668,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
                        return false;
                }
                ostringstream command;
-               command << os::python() << ' ' << quoteName(lyx2lyx)
+               command << os::python() << ' ' << quoteName(lyx2lyx.toFilesystemEncoding())
                        << " -t " << convert<string>(LYX_FORMAT)
                        << " -o " << quoteName(tmpfile) << ' '
                        << quoteName(filename);
@@ -745,7 +747,7 @@ bool Buffer::save() const
        } else {
                // Saving failed, so backup is not backup
                if (lyxrc.make_backup)
-                       rename(s, fileName());
+                       rename(FileName(s), FileName(fileName()));
                return false;
        }
        return true;