#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/os.h"
-#include "support/path.h"
#include "support/systemcall.h"
#include <boost/filesystem/operations.hpp>
+using lyx::docstring;
+using lyx::support::absolutePath;
using lyx::support::bformat;
using lyx::support::compare_ascii_no_case;
using lyx::support::contains;
using lyx::support::libScriptSearch;
using lyx::support::makeDisplayPath;
-using lyx::support::onlyFilename;
using lyx::support::onlyPath;
-using lyx::support::Path;
using lyx::support::quoteName;
using lyx::support::subst;
using lyx::support::Systemcall;
Format::Format(string const & n, string const & e, string const & p,
string const & s, string const & v, string const & ed,
- bool d)
+ bool d)
: name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v),
editor_(ed), document_(d)
{}
namespace {
-string fixCommand(string const & cmd, string const & ext,
+string fixCommand(string const & cmd, string const & ext,
os::auto_open_mode mode)
{
// configure.py says we do not want a viewer/editor
if (it == formatlist.end())
formatlist.push_back(Format(name, extension, prettyname,
shortcut, viewer, editor,
- document));
+ document));
else
*it = Format(name, extension, prettyname, shortcut, viewer,
- editor, document);
+ editor, document);
}
bool Formats::view(Buffer const & buffer, string const & filename,
string const & format_name) const
{
+ BOOST_ASSERT(absolutePath(filename));
if (filename.empty() || !fs::exists(filename)) {
Alert::error(_("Cannot view file"),
bformat(_("File does not exist: %1$s"),
- filename));
+ lyx::from_utf8(filename)));
return false;
}
else {
Alert::error(_("Cannot view file"),
bformat(_("Auto-view file %1$s failed"),
- filename));
+ lyx::from_utf8(filename)));
return false;
}
}
if (!contains(command, token_from))
command += ' ' + token_from;
- command = subst(command, token_from,
- quoteName(onlyFilename(filename)));
+ command = subst(command, token_from, quoteName(filename));
command = subst(command, token_path, quoteName(onlyPath(filename)));
command = subst(command, token_socket, quoteName(lyxsocket->address()));
lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
- buffer.message(_("Executing command: ") + command);
+ buffer.message(_("Executing command: ") + lyx::from_utf8(command));
- Path p(onlyPath(filename));
Systemcall one;
int const res = one.startscript(Systemcall::DontWait, command);
bool Formats::edit(Buffer const & buffer, string const & filename,
string const & format_name) const
{
+ BOOST_ASSERT(absolutePath(filename));
if (filename.empty() || !fs::exists(filename)) {
Alert::error(_("Cannot edit file"),
bformat(_("File does not exist: %1$s"),
- filename));
+ lyx::from_utf8(filename)));
return false;
}
else {
Alert::error(_("Cannot edit file"),
bformat(_("Auto-edit file %1$s failed"),
- filename));
+ lyx::from_utf8(filename)));
return false;
}
}
if (!contains(command, token_from))
command += ' ' + token_from;
- command = subst(command, token_from,
- quoteName(onlyFilename(filename)));
+ command = subst(command, token_from, quoteName(filename));
command = subst(command, token_path, quoteName(onlyPath(filename)));
command = subst(command, token_socket, quoteName(lyxsocket->address()));
lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
- buffer.message(_("Executing command: ") + command);
+ buffer.message(_("Executing command: ") + lyx::from_utf8(command));
- Path p(onlyPath(filename));
Systemcall one;
int const res = one.startscript(Systemcall::DontWait, command);
}
-string const Formats::prettyName(string const & name) const
+docstring const Formats::prettyName(string const & name) const
{
Format const * format = getFormat(name);
if (format)
- return format->prettyname();
+ return lyx::from_utf8(format->prettyname());
else
- return name;
+ return lyx::from_utf8(name);
}