22 files changed:
using support::addPath;
using support::bformat;
using support::FileFilterList;
using support::addPath;
using support::bformat;
using support::FileFilterList;
+using support::FileName;
using support::fileSearch;
using support::isDirWriteable;
using support::fileSearch;
using support::isDirWriteable;
+using support::isFileReadable;
using support::makeDisplayPath;
using support::makeAbsPath;
using support::package;
using support::makeDisplayPath;
using support::makeAbsPath;
using support::package;
buffer_->saveCursor(cursor_.selectionBegin(),
cursor_.selectionEnd());
// current buffer is going to be switched-off, save cursor pos
buffer_->saveCursor(cursor_.selectionBegin(),
cursor_.selectionEnd());
// current buffer is going to be switched-off, save cursor pos
- LyX::ref().session().lastFilePos().save(buffer_->fileName(),
+ LyX::ref().session().lastFilePos().save(FileName(buffer_->fileName()),
boost::tie(cursor_.pit(), cursor_.pos()) );
}
boost::tie(cursor_.pit(), cursor_.pos()) );
}
-bool BufferView::loadLyXFile(string const & filename, bool tolastfiles)
+bool BufferView::loadLyXFile(FileName const & filename, bool tolastfiles)
- // Get absolute path of file and add ".lyx"
- // to the filename if necessary
- string s = fileSearch(string(), filename, "lyx").absFilename();
-
- bool const found = !s.empty();
-
- if (!found)
- s = filename;
-
- if (theBufferList().exists(s)) {
- docstring const file = makeDisplayPath(s, 20);
+ if (theBufferList().exists(filename.absFilename())) {
+ docstring const file = makeDisplayPath(filename.absFilename(), 20);
docstring text = bformat(_("The document %1$s is already "
"loaded.\n\nDo you want to revert "
"to the saved version?"), file);
docstring text = bformat(_("The document %1$s is already "
"loaded.\n\nDo you want to revert "
"to the saved version?"), file);
text, 0, 1, _("&Revert"), _("&Switch to document"));
if (ret != 0) {
text, 0, 1, _("&Revert"), _("&Switch to document"));
if (ret != 0) {
- setBuffer(theBufferList().getBuffer(s));
+ setBuffer(theBufferList().getBuffer(filename.absFilename()));
return true;
}
// FIXME: should be LFUN_REVERT
return true;
}
// FIXME: should be LFUN_REVERT
- if (!theBufferList().close(theBufferList().getBuffer(s), false))
+ if (!theBufferList().close(theBufferList().getBuffer(filename.absFilename()), false))
return false;
// Fall through to new load. (Asger)
buffer_ = 0;
return false;
// Fall through to new load. (Asger)
buffer_ = 0;
- if (found) {
- b = theBufferList().newBuffer(s);
- if (!lyx::loadLyXFile(b, s)) {
+ if (isFileReadable(filename)) {
+ b = theBufferList().newBuffer(filename.absFilename());
+ if (!lyx::loadLyXFile(b, filename)) {
theBufferList().release(b);
return false;
}
} else {
docstring text = bformat(_("The document %1$s does not yet "
"exist.\n\nDo you want to create "
theBufferList().release(b);
return false;
}
} else {
docstring text = bformat(_("The document %1$s does not yet "
"exist.\n\nDo you want to create "
- "a new document?"), from_utf8(s));
+ "a new document?"), from_utf8(filename.absFilename()));
int const ret = Alert::prompt(_("Create new document?"),
text, 0, 1, _("&Create"), _("Cancel"));
if (ret == 0) {
int const ret = Alert::prompt(_("Create new document?"),
text, 0, 1, _("&Create"), _("Cancel"));
if (ret == 0) {
- b = newFile(s, string(), true);
+ b = newFile(filename.absFilename(), string(), true);
if (!b)
return false;
} else
if (!b)
return false;
} else
if (lyxrc.use_lastfilepos) {
pit_type pit;
pos_type pos;
if (lyxrc.use_lastfilepos) {
pit_type pit;
pos_type pos;
- boost::tie(pit, pos) = LyX::ref().session().lastFilePos().load(s);
+ boost::tie(pit, pos) = LyX::ref().session().lastFilePos().load(filename);
// I am not sure how to separate the following part to a function
// so I will leave this to Lars.
//
// I am not sure how to separate the following part to a function
// so I will leave this to Lars.
//
- LyX::ref().session().lastFiles().add(b->fileName());
+ LyX::ref().session().lastFiles().add(FileName(b->fileName()));
void BufferView::reload()
{
void BufferView::reload()
{
- string const fn = buffer_->fileName();
if (theBufferList().close(buffer_, false))
if (theBufferList().close(buffer_, false))
+ loadLyXFile(FileName(buffer_->fileName()));
void BufferView::saveBookmark(bool persistent)
{
LyX::ref().session().bookmarks().save(
void BufferView::saveBookmark(bool persistent)
{
LyX::ref().session().bookmarks().save(
+ FileName(buffer_->fileName()),
cursor_.paragraph().id(),
cursor_.pos(),
persistent
cursor_.paragraph().id(),
cursor_.pos(),
persistent
docstring res;
Buffer buf("", false);
docstring res;
Buffer buf("", false);
- if (lyx::loadLyXFile(&buf, makeAbsPath(filename))) {
+ if (lyx::loadLyXFile(&buf, FileName(filename))) {
ErrorList & el = buffer_->errorList("Parse");
// Copy the inserted document error list into the current buffer one.
el = buf.errorList("Parse");
ErrorList & el = buffer_->errorList("Parse");
// Copy the inserted document error list into the current buffer one.
el = buf.errorList("Parse");
+namespace support { class FileName; }
+
class Buffer;
class Change;
class DocIterator;
class Buffer;
class Change;
class DocIterator;
/// redisplay the referenced buffer.
void reload();
/// load a buffer into the view.
/// redisplay the referenced buffer.
void reload();
/// load a buffer into the view.
- bool loadLyXFile(std::string const & name, bool tolastfiles = true);
+ bool loadLyXFile(support::FileName const & name, bool tolastfiles = true);
/// perform pending painting updates.
/** \c fitcursor means first
/// perform pending painting updates.
/** \c fitcursor means first
int retval = NO_ERRORS;
string tmp = onlyFilename(changeExtension(file, ".log"));
lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
int retval = NO_ERRORS;
string tmp = onlyFilename(changeExtension(file, ".log"));
lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
- ifstream ifs(tmp.c_str());
+ ifstream ifs(FileName(makeAbsPath(tmp)).toFilesystemEncoding().c_str());
string token;
while (getline(ifs, token)) {
string token;
while (getline(ifs, token)) {
// This line is not present if no toc should be created.
static regex miktexTocReg("\\\\tf@toc=\\\\write.*");
// This line is not present if no toc should be created.
static regex miktexTocReg("\\\\tf@toc=\\\\write.*");
- ifstream ifs(logfile.c_str());
+ ifstream ifs(FileName(makeAbsPath(logfile)).toFilesystemEncoding().c_str());
while (ifs) {
// Ok, the scanning of files here is not sufficient.
// Sometimes files are named by "File:Â xxx" only
while (ifs) {
// Ok, the scanning of files here is not sufficient.
// Sometimes files are named by "File:Â xxx" only
int ii = 1;
for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) {
int ii = 1;
for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) {
+ string const file = lfit->absFilename();
docstring const label = convert<docstring>(ii) + ". "
docstring const label = convert<docstring>(ii) + ". "
- + makeDisplayPath((*lfit), 30)
+ + makeDisplayPath(file, 30)
+ char_type('|') + convert<docstring>(ii);
+ char_type('|') + convert<docstring>(ii);
- tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, (*lfit))));
+ tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, file)));
for (size_t i = 1; i <= bm.size(); ++i) {
if (bm.isValid(i)) {
docstring const label = convert<docstring>(i) + ". "
for (size_t i = 1; i <= bm.size(); ++i) {
if (bm.isValid(i)) {
docstring const label = convert<docstring>(i) + ". "
- + makeDisplayPath(bm.bookmark(i).filename, 20)
+ + makeDisplayPath(bm.bookmark(i).filename.absFilename(), 20)
+ char_type('|') + convert<docstring>(i);
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BOOKMARK_GOTO,
convert<docstring>(i))));
+ char_type('|') + convert<docstring>(i);
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BOOKMARK_GOTO,
convert<docstring>(i))));
using support::bformat;
using support::FileName;
using support::libFileSearch;
using support::bformat;
using support::FileName;
using support::libFileSearch;
-using support::makeAbsPath;
using support::makeDisplayPath;
using support::onlyFilename;
using support::onlyPath;
using support::makeDisplayPath;
using support::onlyFilename;
using support::onlyPath;
-bool readFile(Buffer * const b, string const & s)
+bool readFile(Buffer * const b, FileName const & s)
{
BOOST_ASSERT(b);
// File information about normal file
{
BOOST_ASSERT(b);
// File information about normal file
- if (!fs::exists(s)) {
- docstring const file = makeDisplayPath(s, 50);
+ if (!fs::exists(s.toFilesystemEncoding())) {
+ docstring const file = makeDisplayPath(s.absFilename(), 50);
docstring text = bformat(_("The specified document\n%1$s"
"\ncould not be read."), file);
Alert::error(_("Could not read document"), text);
docstring text = bformat(_("The specified document\n%1$s"
"\ncould not be read."), file);
Alert::error(_("Could not read document"), text);
}
// Check if emergency save file exists and is newer.
}
// Check if emergency save file exists and is newer.
- string const e = onlyPath(s) + onlyFilename(s) + ".emergency";
+ FileName const e(s.absFilename() + ".emergency");
- if (fs::exists(e) && fs::exists(s)
- && fs::last_write_time(e) > fs::last_write_time(s))
+ if (fs::exists(e.toFilesystemEncoding()) &&
+ fs::exists(s.toFilesystemEncoding()) &&
+ fs::last_write_time(e.toFilesystemEncoding()) > fs::last_write_time(s.toFilesystemEncoding()))
- docstring const file = makeDisplayPath(s, 20);
+ docstring const file = makeDisplayPath(s.absFilename(), 20);
docstring const text =
bformat(_("An emergency save of the document "
"%1$s exists.\n\n"
docstring const text =
bformat(_("An emergency save of the document "
"%1$s exists.\n\n"
case 0:
// the file is not saved if we load the emergency file.
b->markDirty();
case 0:
// the file is not saved if we load the emergency file.
b->markDirty();
+ return b->readFile(e.absFilename());
}
// Now check if autosave file is newer.
}
// Now check if autosave file is newer.
- string const a = onlyPath(s) + '#' + onlyFilename(s) + '#';
+ FileName const a(onlyPath(s.absFilename()) + '#' + onlyFilename(s.absFilename()) + '#');
- if (fs::exists(a) && fs::exists(s)
- && fs::last_write_time(a) > fs::last_write_time(s))
+ if (fs::exists(a.toFilesystemEncoding()) &&
+ fs::exists(s.toFilesystemEncoding()) &&
+ fs::last_write_time(a.toFilesystemEncoding()) > fs::last_write_time(s.toFilesystemEncoding()))
- docstring const file = makeDisplayPath(s, 20);
+ docstring const file = makeDisplayPath(s.absFilename(), 20);
docstring const text =
bformat(_("The backup of the document "
"%1$s is newer.\n\nLoad the "
docstring const text =
bformat(_("The backup of the document "
"%1$s is newer.\n\nLoad the "
case 0:
// the file is not saved if we load the autosave file.
b->markDirty();
case 0:
// the file is not saved if we load the autosave file.
b->markDirty();
+ return b->readFile(a.absFilename());
case 1:
// Here we delete the autosave
case 1:
// Here we delete the autosave
- unlink(FileName(makeAbsPath(a)));
break;
default:
return false;
}
}
break;
default:
return false;
}
}
+ return b->readFile(s.absFilename());
-bool loadLyXFile(Buffer * b, string const & s)
+bool loadLyXFile(Buffer * b, FileName const & s)
- if (fs::is_readable(s)) {
+ if (fs::is_readable(s.toFilesystemEncoding())) {
if (readFile(b, s)) {
b->lyxvc().file_found_hook(s);
if (readFile(b, s)) {
b->lyxvc().file_found_hook(s);
- if (!fs::is_writable(s))
+ if (!fs::is_writable(s.toFilesystemEncoding()))
b->setReadonly(true);
return true;
}
} else {
b->setReadonly(true);
return true;
}
} else {
- docstring const file = makeDisplayPath(s, 20);
+ docstring const file = makeDisplayPath(s.absFilename(), 20);
// Here we probably should run
if (LyXVC::file_not_found_hook(s)) {
docstring const text =
// Here we probably should run
if (LyXVC::file_not_found_hook(s)) {
docstring const text =
+namespace support { class FileName; }
class Buffer;
class DocIterator;
class Buffer;
class DocIterator;
* Loads a LyX file \c filename into \c Buffer
* and \return success status.
*/
* Loads a LyX file \c filename into \c Buffer
* and \return success status.
*/
-bool loadLyXFile(Buffer *, std::string const & filename);
+bool loadLyXFile(Buffer *, support::FileName const & filename);
/* Make a new file (buffer) with name \c filename based on a template
* named \c templatename
/* Make a new file (buffer) with name \c filename based on a template
* named \c templatename
// if master/slave are both open, do not save slave since it
// will be automatically loaded when the master is loaded
if ((*it)->getMasterBuffer() == (*it))
// if master/slave are both open, do not save slave since it
// will be automatically loaded when the master is loaded
if ((*it)->getMasterBuffer() == (*it))
- LyX::ref().session().lastOpened().add((*it)->fileName());
+ LyX::ref().session().lastOpened().add(FileName((*it)->fileName()));
# include <unistd.h>
#endif
# include <unistd.h>
#endif
-using lyx::frontend::WorkArea;
+using frontend::WorkArea;
-using lyx::docstring;
-using lyx::support::bformat;
-using lyx::support::makeDisplayPath;
-using lyx::support::onlyFilename;
+using support::bformat;
+using support::FileName;
+using support::makeDisplayPath;
+using support::onlyFilename;
using std::endl;
using std::string;
using std::endl;
using std::string;
-bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
+bool LyXView::loadLyXFile(FileName const & filename, bool tolastfiles)
+namespace support { class FileName; }
+
class Buffer;
class InsetBase;
class Menubar;
class Buffer;
class InsetBase;
class Menubar;
//@}
/// load a buffer into the current workarea
//@}
/// load a buffer into the current workarea
- bool loadLyXFile(std::string const & name, bool tolastfiles = true);
+ bool loadLyXFile(support::FileName const & name, bool tolastfiles = true);
/// set a buffer to the current workarea
void setBuffer(Buffer * b);
/// set a buffer to the current workarea
void setBuffer(Buffer * b);
-bool Importer::Import(LyXView * lv, string const & filename,
+bool Importer::Import(LyXView * lv, FileName const & filename,
string const & format, ErrorList & errorList)
{
string const & format, ErrorList & errorList)
{
- docstring const displaypath = makeDisplayPath(filename);
+ docstring const displaypath = makeDisplayPath(filename.absFilename());
lv->message(bformat(_("Importing %1$s..."), displaypath));
lv->message(bformat(_("Importing %1$s..."), displaypath));
- string const lyxfile = changeExtension(filename, ".lyx");
+ FileName const lyxfile(changeExtension(filename.absFilename(), ".lyx"));
string loader_format;
vector<string> loaders = Loaders();
string loader_format;
vector<string> loaders = Loaders();
it != loaders.end(); ++it) {
if (converters.isReachable(format, *it)) {
string const tofile =
it != loaders.end(); ++it) {
if (converters.isReachable(format, *it)) {
string const tofile =
- changeExtension(filename,
+ changeExtension(filename.absFilename(),
- if (!converters.convert(0, FileName(filename), FileName(tofile),
- FileName(filename), format, *it, errorList))
+ if (!converters.convert(0, filename, FileName(tofile),
+ filename, format, *it, errorList))
return false;
loader_format = *it;
break;
return false;
loader_format = *it;
break;
if (loader_format == "lyx") {
lv->loadLyXFile(lyxfile);
} else {
if (loader_format == "lyx") {
lv->loadLyXFile(lyxfile);
} else {
- Buffer * const b = newFile(lyxfile, string(), true);
+ Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
if (b)
lv->setBuffer(b);
else
return false;
bool as_paragraphs = loader_format == "textparagraph";
if (b)
lv->setBuffer(b);
else
return false;
bool as_paragraphs = loader_format == "textparagraph";
- string filename2 = (loader_format == format) ? filename
- : changeExtension(filename,
+ string filename2 = (loader_format == format) ? filename.absFilename()
+ : changeExtension(filename.absFilename(),
formats.extension(loader_format));
insertAsciiFile(lv->view(), filename2, as_paragraphs);
lv->dispatch(FuncRequest(LFUN_MARK_OFF));
formats.extension(loader_format));
insertAsciiFile(lv->view(), filename2, as_paragraphs);
lv->dispatch(FuncRequest(LFUN_MARK_OFF));
+namespace support { class FileName; }
+
class LyXView;
class ErrorList;
class Format;
class LyXView;
class ErrorList;
class Format;
class Importer {
public:
///
class Importer {
public:
///
- static bool Import(LyXView * lv, std::string const & filename,
+ static bool Import(LyXView * lv, support::FileName const & filename,
std::string const & format, ErrorList & errorList);
///
std::string const & format, ErrorList & errorList);
///
Buffer * buf = theBufferList().getBuffer(included_file);
if (!buf) {
// the readonly flag can/will be wrong, not anymore I think.
Buffer * buf = theBufferList().getBuffer(included_file);
if (!buf) {
// the readonly flag can/will be wrong, not anymore I think.
- if (!fs::exists(included_file))
+ FileName const fullname(included_file);
+ if (!fs::exists(fullname.toFilesystemEncoding()))
return false;
buf = theBufferList().newBuffer(included_file);
return false;
buf = theBufferList().newBuffer(included_file);
- if (!loadLyXFile(buf, included_file))
+ if (!loadLyXFile(buf, fullname))
bool menuWrite(Buffer * buffer)
{
if (buffer->save()) {
bool menuWrite(Buffer * buffer)
{
if (buffer->save()) {
- LyX::ref().session().lastFiles().add(buffer->fileName());
+ LyX::ref().session().lastFiles().add(FileName(buffer->fileName()));
support::init_package(argv[0], cl_system_support, cl_user_support,
support::top_build_dir_is_one_level_up);
support::init_package(argv[0], cl_system_support, cl_user_support,
support::top_build_dir_is_one_level_up);
+ vector<FileName> files;
if (!use_gui) {
// FIXME: create a ConsoleApplication
if (!use_gui) {
// FIXME: create a ConsoleApplication
int LyX::loadFiles(int & argc, char * argv[],
int LyX::loadFiles(int & argc, char * argv[],
- vector<string> & files)
+ vector<FileName> & files)
{
// check for any spurious extra arguments
// other than documents
{
// check for any spurious extra arguments
// other than documents
// frontend.
if (argv[argi][0] == '-')
continue;
// frontend.
if (argv[argi][0] == '-')
continue;
- files.push_back(os::internal_path(argv[argi]));
+ // get absolute path of file and add ".lyx" to
+ // the filename if necessary
+ files.push_back(fileSearch(string(), os::internal_path(argv[argi]), "lyx"));
- files.push_back(i18nLibFileSearch("examples", "splash.lyx").absFilename());
+ files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
Buffer * last_loaded = 0;
Buffer * last_loaded = 0;
- vector<string>::const_iterator it = files.begin();
- vector<string>::const_iterator end = files.end();
+ vector<FileName>::const_iterator it = files.begin();
+ vector<FileName>::const_iterator end = files.end();
for (; it != end; ++it) {
for (; it != end; ++it) {
- // get absolute path of file and add ".lyx" to
- // the filename if necessary
- string s = fileSearch(string(), *it, "lyx").absFilename();
- if (s.empty()) {
- Buffer * const b = newFile(*it, string(), true);
+ if (it->empty()) {
+ Buffer * const b = newFile(it->absFilename(), string(), true);
if (b)
last_loaded = b;
} else {
if (b)
last_loaded = b;
} else {
- Buffer * buf = pimpl_->buffer_list_.newBuffer(s, false);
- if (loadLyXFile(buf, s)) {
+ Buffer * buf = pimpl_->buffer_list_.newBuffer(it->absFilename(), false);
+ if (loadLyXFile(buf, *it)) {
last_loaded = buf;
ErrorList const & el = buf->errorList("Parse");
if (!el.empty())
last_loaded = buf;
ErrorList const & el = buf->errorList("Parse");
if (!el.empty())
-void LyX::restoreGuiSession(vector<string> const & files)
+void LyX::restoreGuiSession(vector<FileName> const & files)
{
LyXView * view = newLyXView();
{
LyXView * view = newLyXView();
// if a file is specified, I assume that user wants to edit *that* file
if (files.empty() && lyxrc.load_session) {
// if a file is specified, I assume that user wants to edit *that* file
if (files.empty() && lyxrc.load_session) {
- vector<string> const & lastopened = pimpl_->session_->lastOpened().getfiles();
+ vector<FileName> const & lastopened = pimpl_->session_->lastOpened().getfiles();
// do not add to the lastfile list since these files are restored from
// last seesion, and should be already there (regular files), or should
// not be added at all (help files).
// do not add to the lastfile list since these files are restored from
// last seesion, and should be already there (regular files), or should
// not be added at all (help files).
#ifndef LYX_MAIN_H
#define LYX_MAIN_H
#ifndef LYX_MAIN_H
#define LYX_MAIN_H
+#include "support/filename.h"
+
#include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
\return exit code failure if any.
*/
int loadFiles(int & argc, char * argv[],
\return exit code failure if any.
*/
int loadFiles(int & argc, char * argv[],
- std::vector<std::string> & files);
+ std::vector<support::FileName> & files);
/// Create a View and restore GUI Session.
/// Create a View and restore GUI Session.
- void restoreGuiSession(std::vector<std::string> const & files);
+ void restoreGuiSession(std::vector<support::FileName> const & files);
/// Initialize RC font for the GUI.
void initGuiFont();
/// Initialize RC font for the GUI.
void initGuiFont();
// might be visible in more than one LyXView.
if (lyx_view_ && lyx_view_->view()->buffer()) {
// save cursor Position for opened files to .lyx/session
// might be visible in more than one LyXView.
if (lyx_view_ && lyx_view_->view()->buffer()) {
// save cursor Position for opened files to .lyx/session
- LyX::ref().session().lastFilePos().save(lyx_view_->buffer()->fileName(),
+ LyX::ref().session().lastFilePos().save(FileName(lyx_view_->buffer()->fileName()),
boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
}
boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
}
setErrorMessage(_("Missing argument"));
break;
}
setErrorMessage(_("Missing argument"));
break;
}
- string const fname = i18nLibFileSearch("doc", arg, "lyx").absFilename();
+ FileName const fname = i18nLibFileSearch("doc", arg, "lyx");
if (fname.empty()) {
lyxerr << "LyX: unable to find documentation file `"
<< arg << "'. Bad installation?" << endl;
break;
}
lyx_view_->message(bformat(_("Opening help file %1$s..."),
if (fname.empty()) {
lyxerr << "LyX: unable to find documentation file `"
<< arg << "'. Bad installation?" << endl;
break;
}
lyx_view_->message(bformat(_("Opening help file %1$s..."),
- makeDisplayPath(fname)));
+ makeDisplayPath(fname.absFilename())));
lyx_view_->loadLyXFile(fname, false);
break;
}
lyx_view_->loadLyXFile(fname, false);
break;
}
} else {
// Must replace extension of the file to be .lyx
// and get full path
} else {
// Must replace extension of the file to be .lyx
// and get full path
- string const s = changeExtension(file_name, ".lyx");
+ FileName const s = fileSearch(string(), changeExtension(file_name, ".lyx"), "lyx");
// Either change buffer or load the file
// Either change buffer or load the file
- if (theBufferList().exists(s)) {
- lyx_view_->setBuffer(theBufferList().getBuffer(s));
+ if (theBufferList().exists(s.absFilename())) {
+ lyx_view_->setBuffer(theBufferList().getBuffer(s.absFilename()));
} else {
lyx_view_->loadLyXFile(s);
}
} else {
lyx_view_->loadLyXFile(s);
}
if (theBufferList().exists(filename))
lyx_view_->setBuffer(theBufferList().getBuffer(filename));
else
if (theBufferList().exists(filename))
lyx_view_->setBuffer(theBufferList().getBuffer(filename));
else
- lyx_view_->loadLyXFile(filename);
+ lyx_view_->loadLyXFile(FileName(filename));
// Set the parent name of the child document.
// This makes insertion of citations and references in the child work,
// when the target is in the parent or another child document.
// Set the parent name of the child document.
// This makes insertion of citations and references in the child work,
// when the target is in the parent or another child document.
unsigned int idx = convert<unsigned int>(to_utf8(cmd.argument()));
BookmarksSection::Bookmark const bm = LyX::ref().session().bookmarks().bookmark(idx);
BOOST_ASSERT(!bm.filename.empty());
unsigned int idx = convert<unsigned int>(to_utf8(cmd.argument()));
BookmarksSection::Bookmark const bm = LyX::ref().session().bookmarks().bookmark(idx);
BOOST_ASSERT(!bm.filename.empty());
+ string const file = bm.filename.absFilename();
// if the file is not opened, open it.
// if the file is not opened, open it.
- if (!theBufferList().exists(bm.filename))
- dispatch(FuncRequest(LFUN_FILE_OPEN, bm.filename));
+ if (!theBufferList().exists(file))
+ dispatch(FuncRequest(LFUN_FILE_OPEN, file));
// open may fail, so we need to test it again
// open may fail, so we need to test it again
- if (theBufferList().exists(bm.filename)) {
+ if (theBufferList().exists(file)) {
// if the current buffer is not that one, switch to it.
// if the current buffer is not that one, switch to it.
- if (lyx_view_->buffer()->fileName() != bm.filename)
- dispatch(FuncRequest(LFUN_BUFFER_SWITCH, bm.filename));
- // BOOST_ASSERT(lyx_view_->buffer()->fileName() != bm.filename);
+ if (lyx_view_->buffer()->fileName() != file)
+ dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
+ // BOOST_ASSERT(lyx_view_->buffer()->fileName() != file);
view()->moveToPosition(bm.par_id, bm.par_pos);
}
break;
view()->moveToPosition(bm.par_id, bm.par_pos);
}
break;
void LyXFunc::menuNew(string const & name, bool fromTemplate)
{
void LyXFunc::menuNew(string const & name, bool fromTemplate)
{
+ // FIXME: initpath is not used. What to do?
string initpath = lyxrc.document_path;
string filename(name);
string initpath = lyxrc.document_path;
string filename(name);
// get absolute path of file and add ".lyx" to the filename if
// necessary
FileName const fullname = fileSearch(string(), filename, "lyx");
// get absolute path of file and add ".lyx" to the filename if
// necessary
FileName const fullname = fileSearch(string(), filename, "lyx");
- BOOST_ASSERT(!fullname.empty());
- filename = fullname.absFilename();
-
- docstring const disp_fn = makeDisplayPath(filename);
+ if (!fullname.empty())
+ filename = fullname.absFilename();
// if the file doesn't exist, let the user create one
if (!fs::exists(fullname.toFilesystemEncoding())) {
// if the file doesn't exist, let the user create one
if (!fs::exists(fullname.toFilesystemEncoding())) {
+ docstring const disp_fn = makeDisplayPath(filename);
lyx_view_->message(bformat(_("Opening document %1$s..."), disp_fn));
docstring str2;
lyx_view_->message(bformat(_("Opening document %1$s..."), disp_fn));
docstring str2;
- if (lyx_view_->loadLyXFile(filename)) {
+ if (lyx_view_->loadLyXFile(fullname)) {
str2 = bformat(_("Document %1$s opened."), disp_fn);
} else {
str2 = bformat(_("Could not open document %1$s"), disp_fn);
str2 = bformat(_("Document %1$s opened."), disp_fn);
} else {
str2 = bformat(_("Could not open document %1$s"), disp_fn);
return;
// get absolute path of file
return;
// get absolute path of file
- filename = makeAbsPath(filename);
+ FileName const fullname(makeAbsPath(filename));
- string const lyxfile = changeExtension(filename, ".lyx");
+ FileName const lyxfile(changeExtension(fullname.absFilename(), ".lyx"));
// Check if the document already is open
// Check if the document already is open
- if (use_gui && theBufferList().exists(lyxfile)) {
- if (!theBufferList().close(theBufferList().getBuffer(lyxfile), true)) {
+ if (use_gui && theBufferList().exists(lyxfile.absFilename())) {
+ if (!theBufferList().close(theBufferList().getBuffer(lyxfile.absFilename()), true)) {
lyx_view_->message(_("Canceled."));
return;
}
lyx_view_->message(_("Canceled."));
return;
}
// if the file exists already, and we didn't do
// -i lyx thefile.lyx, warn
// if the file exists already, and we didn't do
// -i lyx thefile.lyx, warn
- if (fs::exists(lyxfile) && filename != lyxfile) {
- docstring const file = makeDisplayPath(lyxfile, 30);
+ if (fs::exists(lyxfile.toFilesystemEncoding()) && fullname != lyxfile) {
+ docstring const file = makeDisplayPath(lyxfile.absFilename(), 30);
docstring text = bformat(_("The document %1$s already exists.\n\n"
"Do you want to over-write that document?"), file);
docstring text = bformat(_("The document %1$s already exists.\n\n"
"Do you want to over-write that document?"), file);
- Importer::Import(lyx_view_, filename, format, errorList);
+ Importer::Import(lyx_view_, fullname, format, errorList);
// FIXME (Abdel 12/08/06): Is there a need to display the error list here?
}
// FIXME (Abdel 12/08/06): Is there a need to display the error list here?
}
void LyXFunc::closeBuffer()
{
// save current cursor position
void LyXFunc::closeBuffer()
{
// save current cursor position
- LyX::ref().session().lastFilePos().save(lyx_view_->buffer()->fileName(),
+ LyX::ref().session().lastFilePos().save(FileName(lyx_view_->buffer()->fileName()),
boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
if (theBufferList().close(lyx_view_->buffer(), true) && !quitting) {
if (theBufferList().empty()) {
boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
if (theBufferList().close(lyx_view_->buffer(), true) && !quitting) {
if (theBufferList().empty()) {
-bool LyXVC::file_found_hook(string const & fn)
+bool LyXVC::file_found_hook(FileName const & fn)
// Check if file is under RCS
if (!(found_file = RCS::find_file(fn)).empty()) {
vcs.reset(new RCS(found_file));
// Check if file is under RCS
if (!(found_file = RCS::find_file(fn)).empty()) {
vcs.reset(new RCS(found_file));
-bool LyXVC::file_not_found_hook(string const & fn)
+bool LyXVC::file_not_found_hook(FileName const & fn)
{
// Check if file is under RCS
if (!RCS::find_file(fn).empty())
{
// Check if file is under RCS
if (!RCS::find_file(fn).empty())
void LyXVC::registrer()
{
void LyXVC::registrer()
{
- string const filename = owner_->fileName();
+ FileName const filename(owner_->fileName());
// there must be a file to save
// there must be a file to save
- if (!isFileReadable(FileName(makeAbsPath(filename)))) {
+ if (!isFileReadable(filename)) {
Alert::error(_("Document not saved"),
_("You must save the document "
"before it can be registered."));
Alert::error(_("Document not saved"),
_("You must save the document "
"before it can be registered."));
// it is very likely here that the vcs is not created yet...
if (!vcs) {
// it is very likely here that the vcs is not created yet...
if (!vcs) {
- string const cvs_entries = "CVS/Entries";
+ FileName const cvs_entries(makeAbsPath("CVS/Entries"));
- if (isFileReadable(FileName(makeAbsPath(cvs_entries)))) {
+ if (isFileReadable(cvs_entries)) {
lyxerr[Debug::LYXVC]
<< "LyXVC: registering "
lyxerr[Debug::LYXVC]
<< "LyXVC: registering "
- << to_utf8(makeDisplayPath(filename))
+ << to_utf8(makeDisplayPath(filename.absFilename()))
<< " with CVS" << endl;
vcs.reset(new CVS(cvs_entries, filename));
} else {
lyxerr[Debug::LYXVC]
<< "LyXVC: registering "
<< " with CVS" << endl;
vcs.reset(new CVS(cvs_entries, filename));
} else {
lyxerr[Debug::LYXVC]
<< "LyXVC: registering "
- << to_utf8(makeDisplayPath(filename))
+ << to_utf8(makeDisplayPath(filename.absFilename()))
<< " with RCS" << endl;
vcs.reset(new RCS(filename));
}
<< " with RCS" << endl;
vcs.reset(new RCS(filename));
}
if (!vcs)
return string();
if (!vcs)
return string();
- string tmpf = tempName(string(), "lyxvclog");
+ FileName const tmpf(tempName(string(), "lyxvclog"));
if (tmpf.empty()) {
lyxerr[Debug::LYXVC] << "Could not generate logfile "
<< tmpf << endl;
if (tmpf.empty()) {
lyxerr[Debug::LYXVC] << "Could not generate logfile "
<< tmpf << endl;
}
lyxerr[Debug::LYXVC] << "Generating logfile " << tmpf << endl;
vcs->getLog(tmpf);
}
lyxerr[Debug::LYXVC] << "Generating logfile " << tmpf << endl;
vcs->getLog(tmpf);
+ return tmpf.absFilename();
+namespace support { class FileName; }
the appropiate actions is taken. Returns true if the file is under
control by a VCS.
*/
the appropiate actions is taken. Returns true if the file is under
control by a VCS.
*/
- bool file_found_hook(std::string const & fn);
+ bool file_found_hook(support::FileName const & fn);
/** This function should be run when a file is requested for loading,
but it does not exist. This function will then check for a VC master
/** This function should be run when a file is requested for loading,
but it does not exist. This function will then check for a VC master
viewing/editing. Returns true if the file is under control by a VCS
and the user wants to view/edit it.
*/
viewing/editing. Returns true if the file is under control by a VCS
and the user wants to view/edit it.
*/
- static bool file_not_found_hook(std::string const & fn);
+ static bool file_not_found_hook(support::FileName const & fn);
///
void buffer(Buffer *);
///
void buffer(Buffer *);
#include <algorithm>
#include <iterator>
#include <algorithm>
#include <iterator>
+using lyx::support::absolutePath;
using lyx::support::addName;
using lyx::support::addName;
+using lyx::support::FileName;
using lyx::support::package;
namespace fs = boost::filesystem;
using lyx::support::package;
namespace fs = boost::filesystem;
if (c == '[')
break;
getline(is, tmp);
if (c == '[')
break;
getline(is, tmp);
- if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ')
+ if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ' || !absolutePath(tmp))
continue;
// read lastfiles
continue;
// read lastfiles
- if (fs::exists(tmp) && !fs::is_directory(tmp) && lastfiles.size() < num_lastfiles)
- lastfiles.push_back(tmp);
+ FileName const file(tmp);
+ if (fs::exists(file.toFilesystemEncoding()) &&
+ !fs::is_directory(file.toFilesystemEncoding()) &&
+ lastfiles.size() < num_lastfiles)
+ lastfiles.push_back(file);
else
lyxerr[Debug::INIT] << "LyX: Warning: Ignore last file: " << tmp << endl;
} while (is.good());
else
lyxerr[Debug::INIT] << "LyX: Warning: Ignore last file: " << tmp << endl;
} while (is.good());
{
os << '\n' << sec_lastfiles << '\n';
copy(lastfiles.begin(), lastfiles.end(),
{
os << '\n' << sec_lastfiles << '\n';
copy(lastfiles.begin(), lastfiles.end(),
- ostream_iterator<string>(os, "\n"));
+ ostream_iterator<FileName>(os, "\n"));
-void LastFilesSection::add(string const & file)
+void LastFilesSection::add(FileName const & file)
{
// If file already exist, delete it and reinsert at front.
LastFiles::iterator it = find(lastfiles.begin(), lastfiles.end(), file);
{
// If file already exist, delete it and reinsert at front.
LastFiles::iterator it = find(lastfiles.begin(), lastfiles.end(), file);
if (c == '[')
break;
getline(is, tmp);
if (c == '[')
break;
getline(is, tmp);
- if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ')
+ if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ' || !absolutePath(tmp))
- if (fs::exists(tmp) && !fs::is_directory(tmp))
- lastopened.push_back(tmp);
+ FileName const file(tmp);
+ if (fs::exists(file.toFilesystemEncoding()) &&
+ !fs::is_directory(file.toFilesystemEncoding()))
+ lastopened.push_back(file);
else
lyxerr[Debug::INIT] << "LyX: Warning: Ignore last opened file: " << tmp << endl;
} while (is.good());
else
lyxerr[Debug::INIT] << "LyX: Warning: Ignore last opened file: " << tmp << endl;
} while (is.good());
{
os << '\n' << sec_lastopened << '\n';
copy(lastopened.begin(), lastopened.end(),
{
os << '\n' << sec_lastopened << '\n';
copy(lastopened.begin(), lastopened.end(),
- ostream_iterator<string>(os, "\n"));
+ ostream_iterator<FileName>(os, "\n"));
-void LastOpenedSection::add(string const & file)
+void LastOpenedSection::add(FileName const & file)
{
lastopened.push_back(file);
}
{
lastopened.push_back(file);
}
itmp >> pos;
itmp.ignore(2); // ignore ", "
itmp >> fname;
itmp >> pos;
itmp.ignore(2); // ignore ", "
itmp >> fname;
- if (fs::exists(fname) && !fs::is_directory(fname) && lastfilepos.size() < num_lastfilepos)
- lastfilepos[fname] = boost::tie(pit, pos);
+ if (!absolutePath(fname))
+ continue;
+ FileName const file(fname);
+ if (fs::exists(file.toFilesystemEncoding()) &&
+ !fs::is_directory(file.toFilesystemEncoding()) &&
+ lastfilepos.size() < num_lastfilepos)
+ lastfilepos[file] = boost::tie(pit, pos);
else
lyxerr[Debug::INIT] << "LyX: Warning: Ignore pos of last file: " << fname << endl;
} catch (...) {
else
lyxerr[Debug::INIT] << "LyX: Warning: Ignore pos of last file: " << fname << endl;
} catch (...) {
-void LastFilePosSection::save(string const & fname, FilePos pos)
+void LastFilePosSection::save(FileName const & fname, FilePos pos)
{
lastfilepos[fname] = pos;
}
{
lastfilepos[fname] = pos;
}
-LastFilePosSection::FilePos LastFilePosSection::load(string const & fname) const
+LastFilePosSection::FilePos LastFilePosSection::load(FileName const & fname) const
{
FilePosMap::const_iterator entry = lastfilepos.find(fname);
// Has position information, return it.
{
FilePosMap::const_iterator entry = lastfilepos.find(fname);
// Has position information, return it.
itmp >> pos;
itmp.ignore(2); // ignore ", "
itmp >> fname;
itmp >> pos;
itmp.ignore(2); // ignore ", "
itmp >> fname;
+ if (!absolutePath(fname))
+ continue;
+ FileName const file(fname);
// only load valid bookmarks
// only load valid bookmarks
- if (fs::exists(fname) && !fs::is_directory(fname) && bookmarks.size() < max_bookmarks)
- bookmarks.push_back(Bookmark(fname, id, pos));
- else
+ if (fs::exists(file.toFilesystemEncoding()) &&
+ !fs::is_directory(file.toFilesystemEncoding()) &&
+ bookmarks.size() < max_bookmarks)
+ bookmarks.push_back(Bookmark(file, id, pos));
+ else
lyxerr[Debug::INIT] << "LyX: Warning: Ignore bookmark of file: " << fname << endl;
} catch (...) {
lyxerr[Debug::INIT] << "LyX: Warning: unknown Bookmark info: " << tmp << endl;
lyxerr[Debug::INIT] << "LyX: Warning: Ignore bookmark of file: " << fname << endl;
} catch (...) {
lyxerr[Debug::INIT] << "LyX: Warning: unknown Bookmark info: " << tmp << endl;
-void BookmarksSection::save(std::string const & fname, int par_id, pos_type par_pos, bool persistent)
+void BookmarksSection::save(FileName const & fname, int par_id, pos_type par_pos, bool persistent)
{
if (persistent) {
bookmarks.push_front(Bookmark(fname, par_id, par_pos));
{
if (persistent) {
bookmarks.push_front(Bookmark(fname, par_id, par_pos));
{
// locate the session file
// note that the session file name 'session' is hard-coded
{
// locate the session file
// note that the session file name 'session' is hard-coded
- session_file = addName(package().user_support(), "session");
+ session_file = FileName(addName(package().user_support(), "session"));
{
// we will not complain if we can't find session_file nor will
// we issue a warning. (Lgb)
{
// we will not complain if we can't find session_file nor will
// we issue a warning. (Lgb)
- ifstream is(session_file.c_str());
+ ifstream is(session_file.toFilesystemEncoding().c_str());
string tmp;
while (getline(is, tmp)) {
string tmp;
while (getline(is, tmp)) {
void Session::writeFile() const
{
void Session::writeFile() const
{
- ofstream os(session_file.c_str());
+ ofstream os(session_file.toFilesystemEncoding().c_str());
if (os) {
os << "## Automatically generated lyx session file \n"
<< "## Editing this file manually may cause lyx to crash.\n";
if (os) {
os << "## Automatically generated lyx session file \n"
<< "## Editing this file manually may cause lyx to crash.\n";
#ifndef SESSION_H
#define SESSION_H
#ifndef SESSION_H
#define SESSION_H
-#include <support/types.h>
+#include "support/filename.h"
+#include "support/types.h"
#include <boost/utility.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/utility.hpp>
#include <boost/tuple/tuple.hpp>
- typedef std::deque<std::string> LastFiles;
+ typedef std::deque<support::FileName> LastFiles;
file in the list is popped from the end.
@param file the file to insert in the lastfile list.
*/
file in the list is popped from the end.
@param file the file to insert in the lastfile list.
*/
- void add(std::string const & file);
+ void add(support::FileName const & file);
private:
/// Default number of lastfiles.
private:
/// Default number of lastfiles.
- typedef std::vector<std::string> LastOpened;
+ typedef std::vector<support::FileName> LastOpened;
/** add file to lastopened file list
@param file filename to add
*/
/** add file to lastopened file list
@param file filename to add
*/
- void add(std::string const & file);
+ void add(support::FileName const & file);
/** clear lastopened file list
*/
/** clear lastopened file list
*/
typedef boost::tuple<pit_type, pos_type> FilePos;
///
typedef boost::tuple<pit_type, pos_type> FilePos;
///
- typedef std::map<std::string, FilePos> FilePosMap;
+ typedef std::map<support::FileName, FilePos> FilePosMap;
@param fname file entry for which to save position information
@param pos position of the cursor when the file is closed.
*/
@param fname file entry for which to save position information
@param pos position of the cursor when the file is closed.
*/
- void save(std::string const & fname, FilePos pos);
+ void save(support::FileName const & fname, FilePos pos);
/** load saved cursor position from the fname entry in the filepos map
@param fname file entry for which to load position information
*/
/** load saved cursor position from the fname entry in the filepos map
@param fname file entry for which to load position information
*/
- FilePos load(std::string const & fname) const;
+ FilePos load(support::FileName const & fname) const;
private:
/// default number of lastfilepos to save */
private:
/// default number of lastfilepos to save */
class Bookmark {
public:
/// Filename
class Bookmark {
public:
/// Filename
+ support::FileName filename;
/// Cursor paragraph Id
int par_id;
/// Cursor position
/// Cursor paragraph Id
int par_id;
/// Cursor position
///
Bookmark() : par_id(0), par_pos(0) {}
///
///
Bookmark() : par_id(0), par_pos(0) {}
///
- Bookmark(std::string const & f, int id, pos_type pos)
+ Bookmark(support::FileName const & f, int id, pos_type pos)
: filename(f), par_id(id), par_pos(pos) {}
};
: filename(f), par_id(id), par_pos(pos) {}
};
/// Save the current position as bookmark
/// if save==false, save to temp_bookmark
/// Save the current position as bookmark
/// if save==false, save to temp_bookmark
- void save(std::string const & fname, int par_id, pos_type par_pos, bool persistent);
+ void save(support::FileName const & fname, int par_id, pos_type par_pos, bool persistent);
/// return bookmark, return temp_bookmark if i==0
Bookmark const & bookmark(unsigned int i) const;
/// return bookmark, return temp_bookmark if i==0
Bookmark const & bookmark(unsigned int i) const;
private:
/// file to save session, determined in the constructor.
private:
/// file to save session, determined in the constructor.
- std::string session_file;
+ support::FileName session_file;
/** Read the session file.
Reads the #.lyx/session# at the beginning of the LyX session.
/** Read the session file.
Reads the #.lyx/session# at the beginning of the LyX session.
using support::addName;
using support::addPath;
using support::contains;
using support::addName;
using support::addPath;
using support::contains;
+using support::FileName;
using support::onlyFilename;
using support::onlyPath;
using support::quoteName;
using support::onlyFilename;
using support::onlyPath;
using support::quoteName;
-RCS::RCS(string const & m)
+RCS::RCS(FileName const & m)
{
master_ = m;
scanMaster();
}
{
master_ = m;
scanMaster();
}
-string const RCS::find_file(string const & file)
+FileName const RCS::find_file(FileName const & file)
+ FileName tmp(file.absFilename() + ",v");
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
<< tmp << endl;
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
<< tmp << endl;
- if (fs::is_readable(tmp)) {
+ if (fs::is_readable(tmp.toFilesystemEncoding())) {
lyxerr[Debug::LYXVC] << "Yes " << file
<< " is under rcs." << endl;
return tmp;
} else {
// Check if RCS/*,v exists.
lyxerr[Debug::LYXVC] << "Yes " << file
<< " is under rcs." << endl;
return tmp;
} else {
// Check if RCS/*,v exists.
- tmp = addName(addPath(onlyPath(file), "RCS"), file);
- tmp += ",v";
+ tmp = FileName(addName(addPath(onlyPath(file.absFilename()), "RCS"), file.absFilename()) + ",v");
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
<< tmp << endl;
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
<< tmp << endl;
- if (fs::is_readable(tmp)) {
+ if (fs::is_readable(tmp.toFilesystemEncoding())) {
lyxerr[Debug::LYXVC] << "Yes " << file
<< " it is under rcs."<< endl;
return tmp;
}
}
lyxerr[Debug::LYXVC] << "Yes " << file
<< " it is under rcs."<< endl;
return tmp;
}
}
-void RCS::retrieve(string const & file)
+void RCS::retrieve(FileName const & file)
{
lyxerr[Debug::LYXVC] << "LyXVC::RCS: retrieve.\n\t" << file << endl;
{
lyxerr[Debug::LYXVC] << "LyXVC::RCS: retrieve.\n\t" << file << endl;
- VCS::doVCCommand("co -q -r " + quoteName(file),
+ VCS::doVCCommand("co -q -r " + quoteName(file.toFilesystemEncoding()),
{
lyxerr[Debug::LYXVC] << "LyXVC::RCS: scanMaster." << endl;
{
lyxerr[Debug::LYXVC] << "LyXVC::RCS: scanMaster." << endl;
- ifstream ifs(master_.c_str());
+ ifstream ifs(master_.toFilesystemEncoding().c_str());
string token;
bool read_enough = false;
string token;
bool read_enough = false;
-void RCS::getLog(string const & tmpf)
+void RCS::getLog(FileName const & tmpf)
{
doVCCommand("rlog " + quoteName(onlyFilename(owner_->fileName()))
{
doVCCommand("rlog " + quoteName(onlyFilename(owner_->fileName()))
+ + " > " + tmpf.toFilesystemEncoding(),
-CVS::CVS(string const & m, string const & f)
+CVS::CVS(FileName const & m, FileName const & f)
{
master_ = m;
file_ = f;
{
master_ = m;
file_ = f;
-string const CVS::find_file(string const & file)
+FileName const CVS::find_file(FileName const & file)
{
// First we look for the CVS/Entries in the same dir
// where we have file.
{
// First we look for the CVS/Entries in the same dir
// where we have file.
- string const dir = onlyPath(file) + "/CVS/Entries";
- string const tmpf = "/" + onlyFilename(file) + "/";
+ FileName const dir(onlyPath(file.absFilename()) + "/CVS/Entries");
+ string const tmpf = '/' + onlyFilename(file.absFilename()) + '/';
lyxerr[Debug::LYXVC] << "LyXVC: checking in `" << dir
<< "' for `" << tmpf << '\'' << endl;
lyxerr[Debug::LYXVC] << "LyXVC: checking in `" << dir
<< "' for `" << tmpf << '\'' << endl;
- if (fs::is_readable(dir)) {
+ if (fs::is_readable(dir.toFilesystemEncoding())) {
// Ok we are at least in a CVS dir. Parse the CVS/Entries
// and see if we can find this file. We do a fast and
// dirty parse here.
// Ok we are at least in a CVS dir. Parse the CVS/Entries
// and see if we can find this file. We do a fast and
// dirty parse here.
- ifstream ifs(dir.c_str());
+ ifstream ifs(dir.toFilesystemEncoding().c_str());
string line;
while (getline(ifs, line)) {
lyxerr[Debug::LYXVC] << "\tEntries: " << line << endl;
string line;
while (getline(ifs, line)) {
lyxerr[Debug::LYXVC] << "\tEntries: " << line << endl;
- if (contains(line, tmpf)) return dir;
+ if (contains(line, tmpf))
+ return dir;
lyxerr[Debug::LYXVC] << "LyXVC::CVS: scanMaster. \n Checking: "
<< master_ << endl;
// Ok now we do the real scan...
lyxerr[Debug::LYXVC] << "LyXVC::CVS: scanMaster. \n Checking: "
<< master_ << endl;
// Ok now we do the real scan...
- ifstream ifs(master_.c_str());
- string tmpf = "/" + onlyFilename(file_) + "/";
+ ifstream ifs(master_.toFilesystemEncoding().c_str());
+ string tmpf = '/' + onlyFilename(file_.absFilename()) + '/';
lyxerr[Debug::LYXVC] << "\tlooking for `" << tmpf << '\'' << endl;
string line;
static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
lyxerr[Debug::LYXVC] << "\tlooking for `" << tmpf << '\'' << endl;
string line;
static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
//sm[4]; // options
//sm[5]; // tag or tagdate
// FIXME: must double check file is stattable/existing
//sm[4]; // options
//sm[5]; // tag or tagdate
// FIXME: must double check file is stattable/existing
- time_t mod = fs::last_write_time(file_);
+ time_t mod = fs::last_write_time(file_.toFilesystemEncoding());
string mod_date = rtrim(asctime(gmtime(&mod)), "\n");
lyxerr[Debug::LYXVC]
<< "Date in Entries: `" << file_date
string mod_date = rtrim(asctime(gmtime(&mod)), "\n");
lyxerr[Debug::LYXVC]
<< "Date in Entries: `" << file_date
-void CVS::getLog(string const & tmpf)
+void CVS::getLog(FileName const & tmpf)
{
doVCCommand("cvs log " + quoteName(onlyFilename(owner_->fileName()))
{
doVCCommand("cvs log " + quoteName(onlyFilename(owner_->fileName()))
+ + " > " + tmpf.toFilesystemEncoding(),
#ifndef VC_BACKEND_H
#define VC_BACKEND_H
#ifndef VC_BACKEND_H
#define VC_BACKEND_H
+#include "support/filename.h"
+
* getLog - read the revision log into the given file
* @param fname file name to read into
*/
* getLog - read the revision log into the given file
* @param fname file name to read into
*/
- virtual void getLog(std::string const &) = 0;
+ virtual void getLog(support::FileName const &) = 0;
/// return the current version description
virtual std::string const versionString() const = 0;
/// return the current version
/// return the current version description
virtual std::string const versionString() const = 0;
/// return the current version
* The master VC file. For RCS this is *,v or RCS/ *,v. master should
* have full path.
*/
* The master VC file. For RCS this is *,v or RCS/ *,v. master should
* have full path.
*/
+ support::FileName master_;
/// The status of the VC controlled file.
VCStatus vcstatus;
/// The status of the VC controlled file.
VCStatus vcstatus;
- RCS(std::string const & m);
+ RCS(support::FileName const & m);
/// return the revision file for the given file, if found
/// return the revision file for the given file, if found
- static std::string const find_file(std::string const & file);
+ static support::FileName const find_file(support::FileName const & file);
- static void retrieve(std::string const & file);
+ static void retrieve(support::FileName const & file);
virtual void registrer(std::string const & msg);
virtual void registrer(std::string const & msg);
- virtual void getLog(std::string const &);
+ virtual void getLog(support::FileName const &);
virtual std::string const versionString() const {
return "RCS: " + version_;
virtual std::string const versionString() const {
return "RCS: " + version_;
- CVS(std::string const & m, std::string const & f);
+ CVS(support::FileName const & m, support::FileName const & f);
/// return the revision file for the given file, if found
/// return the revision file for the given file, if found
- static std::string const find_file(std::string const & file);
+ static support::FileName const find_file(support::FileName const & file);
virtual void registrer(std::string const & msg);
virtual void registrer(std::string const & msg);
- virtual void getLog(std::string const &);
+ virtual void getLog(support::FileName const &);
virtual std::string const versionString() const {
return "CVS: " + version_;
virtual std::string const versionString() const {
return "CVS: " + version_;
virtual void scanMaster();
private:
virtual void scanMaster();
private:
+ support::FileName file_;