#include "support/os.h"
#include "support/Systemcall.h"
-#include <boost/filesystem/operations.hpp>
-
+using std::find_if;
using std::string;
using std::distance;
using support::token;
namespace Alert = frontend::Alert;
-namespace fs = boost::filesystem;
namespace os = support::os;
namespace {
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
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
return cmd;
}
-}
void Formats::setAutoOpen()
{
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())));
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())));