]> git.lyx.org Git - lyx.git/blobdiff - src/Format.cpp
* gcc does not like missing characters in keywords
[lyx.git] / src / Format.cpp
index e2107a5bdcc0242781a4abb94f99d493024fce96..ccaf5ab3c0db14d922565518efa2ac1a1cd994d0 100644 (file)
@@ -26,7 +26,9 @@
 #include "support/os.h"
 #include "support/Systemcall.h"
 
-#include <boost/filesystem/operations.hpp>
+using std::find_if;
+using std::string;
+using std::distance;
 
 
 namespace lyx {
@@ -44,11 +46,7 @@ using support::subst;
 using support::Systemcall;
 using support::token;
 
-using std::string;
-using std::distance;
-
 namespace Alert = frontend::Alert;
-namespace fs = boost::filesystem;
 namespace os = support::os;
 
 namespace {
@@ -142,12 +140,12 @@ string Formats::getFormatFromFile(FileName const & filename) const
        if (filename.empty())
                return string();
 
-       string const format = support::getFormatFromContents(filename);
+       string const format = filename.guessFormatFromContents();
        if (!format.empty())
                return format;
 
        // try to find a format from the file extension.
-       string const ext(support::getExtension(filename.absFilename()));
+       string const ext = support::getExtension(filename.absFilename());
        if (!ext.empty()) {
                // this is ambigous if two formats have the same extension,
                // but better than nothing
@@ -164,9 +162,8 @@ string Formats::getFormatFromFile(FileName const & filename) const
        return string();
 }
 
-namespace {
 
-string fixCommand(string const & cmd, string const & ext,
+static string fixCommand(string const & cmd, string const & ext,
                  os::auto_open_mode mode)
 {
        // configure.py says we do not want a viewer/editor
@@ -185,7 +182,6 @@ string fixCommand(string const & cmd, string const & ext,
        return cmd;
 }
 
-}
 
 void Formats::setAutoOpen()
 {
@@ -265,7 +261,7 @@ void Formats::setViewer(string const & name, string const & command)
 bool Formats::view(Buffer const & buffer, FileName const & filename,
                   string const & format_name) const
 {
-       if (filename.empty() || !fs::exists(filename.toFilesystemEncoding())) {
+       if (filename.empty() || !filename.exists()) {
                Alert::error(_("Cannot view file"),
                        bformat(_("File does not exist: %1$s"),
                                from_utf8(filename.absFilename())));
@@ -335,7 +331,7 @@ bool Formats::view(Buffer const & buffer, FileName const & filename,
 bool Formats::edit(Buffer const & buffer, FileName const & filename,
                         string const & format_name) const
 {
-       if (filename.empty() || !fs::exists(filename.toFilesystemEncoding())) {
+       if (filename.empty() || !filename.exists()) {
                Alert::error(_("Cannot edit file"),
                        bformat(_("File does not exist: %1$s"),
                                from_utf8(filename.absFilename())));