mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-13 22:49:20 +00:00
more unicode filenames
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16133 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
591d47a64b
commit
ed99f752f9
@ -83,8 +83,10 @@ namespace lyx {
|
|||||||
using support::addPath;
|
using support::addPath;
|
||||||
using support::bformat;
|
using support::bformat;
|
||||||
using support::FileFilterList;
|
using support::FileFilterList;
|
||||||
|
using support::FileName;
|
||||||
using support::fileSearch;
|
using support::fileSearch;
|
||||||
using support::isDirWriteable;
|
using support::isDirWriteable;
|
||||||
|
using support::isFileReadable;
|
||||||
using support::makeDisplayPath;
|
using support::makeDisplayPath;
|
||||||
using support::makeAbsPath;
|
using support::makeAbsPath;
|
||||||
using support::package;
|
using support::package;
|
||||||
@ -153,7 +155,7 @@ void BufferView::setBuffer(Buffer * b)
|
|||||||
buffer_->saveCursor(cursor_.selectionBegin(),
|
buffer_->saveCursor(cursor_.selectionBegin(),
|
||||||
cursor_.selectionEnd());
|
cursor_.selectionEnd());
|
||||||
// current buffer is going to be switched-off, save cursor pos
|
// 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()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,20 +207,11 @@ void BufferView::setBuffer(Buffer * b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
// File already open?
|
// File already open?
|
||||||
if (theBufferList().exists(s)) {
|
if (theBufferList().exists(filename.absFilename())) {
|
||||||
docstring const file = makeDisplayPath(s, 20);
|
docstring const file = makeDisplayPath(filename.absFilename(), 20);
|
||||||
docstring text = bformat(_("The document %1$s is already "
|
docstring text = bformat(_("The document %1$s is already "
|
||||||
"loaded.\n\nDo you want to revert "
|
"loaded.\n\nDo you want to revert "
|
||||||
"to the saved version?"), file);
|
"to the saved version?"), file);
|
||||||
@ -226,11 +219,11 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles)
|
|||||||
text, 0, 1, _("&Revert"), _("&Switch to document"));
|
text, 0, 1, _("&Revert"), _("&Switch to document"));
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
setBuffer(theBufferList().getBuffer(s));
|
setBuffer(theBufferList().getBuffer(filename.absFilename()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// FIXME: should be LFUN_REVERT
|
// FIXME: should be LFUN_REVERT
|
||||||
if (!theBufferList().close(theBufferList().getBuffer(s), false))
|
if (!theBufferList().close(theBufferList().getBuffer(filename.absFilename()), false))
|
||||||
return false;
|
return false;
|
||||||
// Fall through to new load. (Asger)
|
// Fall through to new load. (Asger)
|
||||||
buffer_ = 0;
|
buffer_ = 0;
|
||||||
@ -238,21 +231,21 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles)
|
|||||||
|
|
||||||
Buffer * b = 0;
|
Buffer * b = 0;
|
||||||
|
|
||||||
if (found) {
|
if (isFileReadable(filename)) {
|
||||||
b = theBufferList().newBuffer(s);
|
b = theBufferList().newBuffer(filename.absFilename());
|
||||||
if (!lyx::loadLyXFile(b, s)) {
|
if (!lyx::loadLyXFile(b, filename)) {
|
||||||
theBufferList().release(b);
|
theBufferList().release(b);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
docstring text = bformat(_("The document %1$s does not yet "
|
docstring text = bformat(_("The document %1$s does not yet "
|
||||||
"exist.\n\nDo you want to create "
|
"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?"),
|
int const ret = Alert::prompt(_("Create new document?"),
|
||||||
text, 0, 1, _("&Create"), _("Cancel"));
|
text, 0, 1, _("&Create"), _("Cancel"));
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
b = newFile(s, string(), true);
|
b = newFile(filename.absFilename(), string(), true);
|
||||||
if (!b)
|
if (!b)
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
@ -267,7 +260,7 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles)
|
|||||||
if (lyxrc.use_lastfilepos) {
|
if (lyxrc.use_lastfilepos) {
|
||||||
pit_type pit;
|
pit_type pit;
|
||||||
pos_type pos;
|
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
|
// I am not sure how to separate the following part to a function
|
||||||
// so I will leave this to Lars.
|
// so I will leave this to Lars.
|
||||||
//
|
//
|
||||||
@ -288,7 +281,7 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tolastfiles)
|
if (tolastfiles)
|
||||||
LyX::ref().session().lastFiles().add(b->fileName());
|
LyX::ref().session().lastFiles().add(FileName(b->fileName()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -296,9 +289,8 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles)
|
|||||||
|
|
||||||
void BufferView::reload()
|
void BufferView::reload()
|
||||||
{
|
{
|
||||||
string const fn = buffer_->fileName();
|
|
||||||
if (theBufferList().close(buffer_, false))
|
if (theBufferList().close(buffer_, false))
|
||||||
loadLyXFile(fn);
|
loadLyXFile(FileName(buffer_->fileName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -532,7 +524,7 @@ Change const BufferView::getCurrentChange() const
|
|||||||
void BufferView::saveBookmark(bool persistent)
|
void BufferView::saveBookmark(bool persistent)
|
||||||
{
|
{
|
||||||
LyX::ref().session().bookmarks().save(
|
LyX::ref().session().bookmarks().save(
|
||||||
buffer_->fileName(),
|
FileName(buffer_->fileName()),
|
||||||
cursor_.paragraph().id(),
|
cursor_.paragraph().id(),
|
||||||
cursor_.pos(),
|
cursor_.pos(),
|
||||||
persistent
|
persistent
|
||||||
@ -1395,7 +1387,7 @@ void BufferView::menuInsertLyXFile(string const & filenm)
|
|||||||
|
|
||||||
docstring res;
|
docstring res;
|
||||||
Buffer buf("", false);
|
Buffer buf("", false);
|
||||||
if (lyx::loadLyXFile(&buf, makeAbsPath(filename))) {
|
if (lyx::loadLyXFile(&buf, FileName(filename))) {
|
||||||
ErrorList & el = buffer_->errorList("Parse");
|
ErrorList & el = buffer_->errorList("Parse");
|
||||||
// Copy the inserted document error list into the current buffer one.
|
// Copy the inserted document error list into the current buffer one.
|
||||||
el = buf.errorList("Parse");
|
el = buf.errorList("Parse");
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
namespace support { class FileName; }
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class Change;
|
class Change;
|
||||||
class DocIterator;
|
class DocIterator;
|
||||||
@ -91,7 +93,7 @@ public:
|
|||||||
/// redisplay the referenced buffer.
|
/// redisplay the referenced buffer.
|
||||||
void reload();
|
void reload();
|
||||||
/// load a buffer into the view.
|
/// 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.
|
/// perform pending painting updates.
|
||||||
/** \c fitcursor means first
|
/** \c fitcursor means first
|
||||||
|
@ -564,7 +564,7 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
int retval = NO_ERRORS;
|
int retval = NO_ERRORS;
|
||||||
string tmp = onlyFilename(changeExtension(file, ".log"));
|
string tmp = onlyFilename(changeExtension(file, ".log"));
|
||||||
lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
|
lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
|
||||||
ifstream ifs(tmp.c_str());
|
ifstream ifs(FileName(makeAbsPath(tmp)).toFilesystemEncoding().c_str());
|
||||||
|
|
||||||
string token;
|
string token;
|
||||||
while (getline(ifs, token)) {
|
while (getline(ifs, token)) {
|
||||||
@ -796,7 +796,7 @@ void LaTeX::deplog(DepTable & head)
|
|||||||
// This line is not present if no toc should be created.
|
// This line is not present if no toc should be created.
|
||||||
static regex miktexTocReg("\\\\tf@toc=\\\\write.*");
|
static regex miktexTocReg("\\\\tf@toc=\\\\write.*");
|
||||||
|
|
||||||
ifstream ifs(logfile.c_str());
|
ifstream ifs(FileName(makeAbsPath(logfile)).toFilesystemEncoding().c_str());
|
||||||
while (ifs) {
|
while (ifs) {
|
||||||
// Ok, the scanning of files here is not sufficient.
|
// Ok, the scanning of files here is not sufficient.
|
||||||
// Sometimes files are named by "File: xxx" only
|
// Sometimes files are named by "File: xxx" only
|
||||||
|
@ -448,10 +448,11 @@ void expandLastfiles(Menu & tomenu)
|
|||||||
int ii = 1;
|
int ii = 1;
|
||||||
|
|
||||||
for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) {
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +487,7 @@ void expandBookmarks(Menu & tomenu)
|
|||||||
for (size_t i = 1; i <= bm.size(); ++i) {
|
for (size_t i = 1; i <= bm.size(); ++i) {
|
||||||
if (bm.isValid(i)) {
|
if (bm.isValid(i)) {
|
||||||
docstring const label = convert<docstring>(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);
|
+ char_type('|') + convert<docstring>(i);
|
||||||
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BOOKMARK_GOTO,
|
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BOOKMARK_GOTO,
|
||||||
convert<docstring>(i))));
|
convert<docstring>(i))));
|
||||||
|
@ -55,7 +55,6 @@ using namespace std;
|
|||||||
using support::bformat;
|
using support::bformat;
|
||||||
using support::FileName;
|
using support::FileName;
|
||||||
using support::libFileSearch;
|
using support::libFileSearch;
|
||||||
using support::makeAbsPath;
|
|
||||||
using support::makeDisplayPath;
|
using support::makeDisplayPath;
|
||||||
using support::onlyFilename;
|
using support::onlyFilename;
|
||||||
using support::onlyPath;
|
using support::onlyPath;
|
||||||
@ -69,13 +68,13 @@ namespace fs = boost::filesystem;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool readFile(Buffer * const b, string const & s)
|
bool readFile(Buffer * const b, FileName const & s)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(b);
|
BOOST_ASSERT(b);
|
||||||
|
|
||||||
// File information about normal file
|
// File information about normal file
|
||||||
if (!fs::exists(s)) {
|
if (!fs::exists(s.toFilesystemEncoding())) {
|
||||||
docstring const file = makeDisplayPath(s, 50);
|
docstring const file = makeDisplayPath(s.absFilename(), 50);
|
||||||
docstring text = bformat(_("The specified document\n%1$s"
|
docstring text = bformat(_("The specified document\n%1$s"
|
||||||
"\ncould not be read."), file);
|
"\ncould not be read."), file);
|
||||||
Alert::error(_("Could not read document"), text);
|
Alert::error(_("Could not read document"), text);
|
||||||
@ -83,12 +82,13 @@ bool readFile(Buffer * const b, string const & s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
if (fs::exists(e.toFilesystemEncoding()) &&
|
||||||
&& fs::last_write_time(e) > fs::last_write_time(s))
|
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 =
|
docstring const text =
|
||||||
bformat(_("An emergency save of the document "
|
bformat(_("An emergency save of the document "
|
||||||
"%1$s exists.\n\n"
|
"%1$s exists.\n\n"
|
||||||
@ -100,7 +100,7 @@ bool readFile(Buffer * const b, string const & s)
|
|||||||
case 0:
|
case 0:
|
||||||
// the file is not saved if we load the emergency file.
|
// the file is not saved if we load the emergency file.
|
||||||
b->markDirty();
|
b->markDirty();
|
||||||
return b->readFile(e);
|
return b->readFile(e.absFilename());
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -109,12 +109,13 @@ bool readFile(Buffer * const b, string const & s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
if (fs::exists(a.toFilesystemEncoding()) &&
|
||||||
&& fs::last_write_time(a) > fs::last_write_time(s))
|
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 =
|
docstring const text =
|
||||||
bformat(_("The backup of the document "
|
bformat(_("The backup of the document "
|
||||||
"%1$s is newer.\n\nLoad the "
|
"%1$s is newer.\n\nLoad the "
|
||||||
@ -126,16 +127,16 @@ bool readFile(Buffer * const b, string const & s)
|
|||||||
case 0:
|
case 0:
|
||||||
// the file is not saved if we load the autosave file.
|
// the file is not saved if we load the autosave file.
|
||||||
b->markDirty();
|
b->markDirty();
|
||||||
return b->readFile(a);
|
return b->readFile(a.absFilename());
|
||||||
case 1:
|
case 1:
|
||||||
// Here we delete the autosave
|
// Here we delete the autosave
|
||||||
unlink(FileName(makeAbsPath(a)));
|
unlink(a);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b->readFile(s);
|
return b->readFile(s.absFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -143,19 +144,19 @@ bool readFile(Buffer * const b, string const & s)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool loadLyXFile(Buffer * b, string const & s)
|
bool loadLyXFile(Buffer * b, FileName const & s)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(b);
|
BOOST_ASSERT(b);
|
||||||
|
|
||||||
if (fs::is_readable(s)) {
|
if (fs::is_readable(s.toFilesystemEncoding())) {
|
||||||
if (readFile(b, s)) {
|
if (readFile(b, s)) {
|
||||||
b->lyxvc().file_found_hook(s);
|
b->lyxvc().file_found_hook(s);
|
||||||
if (!fs::is_writable(s))
|
if (!fs::is_writable(s.toFilesystemEncoding()))
|
||||||
b->setReadonly(true);
|
b->setReadonly(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
docstring const file = makeDisplayPath(s, 20);
|
docstring const file = makeDisplayPath(s.absFilename(), 20);
|
||||||
// Here we probably should run
|
// Here we probably should run
|
||||||
if (LyXVC::file_not_found_hook(s)) {
|
if (LyXVC::file_not_found_hook(s)) {
|
||||||
docstring const text =
|
docstring const text =
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
namespace support { class FileName; }
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class DocIterator;
|
class DocIterator;
|
||||||
@ -31,7 +32,7 @@ class ParIterator;
|
|||||||
* Loads a LyX file \c filename into \c Buffer
|
* Loads a LyX file \c filename into \c Buffer
|
||||||
* and \return success status.
|
* 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
|
/* Make a new file (buffer) with name \c filename based on a template
|
||||||
* named \c templatename
|
* named \c templatename
|
||||||
|
@ -160,7 +160,7 @@ bool BufferList::quitWriteAll()
|
|||||||
// if master/slave are both open, do not save slave since it
|
// if master/slave are both open, do not save slave since it
|
||||||
// will be automatically loaded when the master is loaded
|
// will be automatically loaded when the master is loaded
|
||||||
if ((*it)->getMasterBuffer() == (*it))
|
if ((*it)->getMasterBuffer() == (*it))
|
||||||
LyX::ref().session().lastOpened().add((*it)->fileName());
|
LyX::ref().session().lastOpened().add(FileName((*it)->fileName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -52,12 +52,12 @@ namespace lyx {
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using lyx::frontend::WorkArea;
|
using frontend::WorkArea;
|
||||||
|
|
||||||
using lyx::docstring;
|
using support::bformat;
|
||||||
using lyx::support::bformat;
|
using support::FileName;
|
||||||
using lyx::support::makeDisplayPath;
|
using support::makeDisplayPath;
|
||||||
using lyx::support::onlyFilename;
|
using support::onlyFilename;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -137,7 +137,7 @@ void LyXView::setBuffer(Buffer * b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
|
bool LyXView::loadLyXFile(FileName const & filename, bool tolastfiles)
|
||||||
{
|
{
|
||||||
busy(true);
|
busy(true);
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
namespace support { class FileName; }
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class InsetBase;
|
class InsetBase;
|
||||||
class Menubar;
|
class Menubar;
|
||||||
@ -128,7 +130,7 @@ public:
|
|||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// 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
|
/// set a buffer to the current workarea
|
||||||
void setBuffer(Buffer * b);
|
void setBuffer(Buffer * b);
|
||||||
|
@ -40,13 +40,13 @@ using std::string;
|
|||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
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;
|
string loader_format;
|
||||||
vector<string> loaders = Loaders();
|
vector<string> loaders = Loaders();
|
||||||
@ -55,10 +55,10 @@ bool Importer::Import(LyXView * lv, string const & filename,
|
|||||||
it != loaders.end(); ++it) {
|
it != loaders.end(); ++it) {
|
||||||
if (converters.isReachable(format, *it)) {
|
if (converters.isReachable(format, *it)) {
|
||||||
string const tofile =
|
string const tofile =
|
||||||
changeExtension(filename,
|
changeExtension(filename.absFilename(),
|
||||||
formats.extension(*it));
|
formats.extension(*it));
|
||||||
if (!converters.convert(0, FileName(filename), FileName(tofile),
|
if (!converters.convert(0, filename, FileName(tofile),
|
||||||
FileName(filename), format, *it, errorList))
|
filename, format, *it, errorList))
|
||||||
return false;
|
return false;
|
||||||
loader_format = *it;
|
loader_format = *it;
|
||||||
break;
|
break;
|
||||||
@ -78,14 +78,14 @@ bool Importer::Import(LyXView * lv, string const & filename,
|
|||||||
if (loader_format == "lyx") {
|
if (loader_format == "lyx") {
|
||||||
lv->loadLyXFile(lyxfile);
|
lv->loadLyXFile(lyxfile);
|
||||||
} else {
|
} else {
|
||||||
Buffer * const b = newFile(lyxfile, string(), true);
|
Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
|
||||||
if (b)
|
if (b)
|
||||||
lv->setBuffer(b);
|
lv->setBuffer(b);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
bool as_paragraphs = loader_format == "textparagraph";
|
bool as_paragraphs = loader_format == "textparagraph";
|
||||||
string filename2 = (loader_format == format) ? filename
|
string filename2 = (loader_format == format) ? filename.absFilename()
|
||||||
: changeExtension(filename,
|
: changeExtension(filename.absFilename(),
|
||||||
formats.extension(loader_format));
|
formats.extension(loader_format));
|
||||||
insertAsciiFile(lv->view(), filename2, as_paragraphs);
|
insertAsciiFile(lv->view(), filename2, as_paragraphs);
|
||||||
lv->dispatch(FuncRequest(LFUN_MARK_OFF));
|
lv->dispatch(FuncRequest(LFUN_MARK_OFF));
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
namespace support { class FileName; }
|
||||||
|
|
||||||
class LyXView;
|
class LyXView;
|
||||||
class ErrorList;
|
class ErrorList;
|
||||||
class Format;
|
class Format;
|
||||||
@ -27,7 +29,7 @@ class Format;
|
|||||||
class Importer {
|
class Importer {
|
||||||
public:
|
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);
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -354,10 +354,11 @@ bool loadIfNeeded(Buffer const & buffer, InsetCommandParams const & params)
|
|||||||
Buffer * buf = theBufferList().getBuffer(included_file);
|
Buffer * buf = theBufferList().getBuffer(included_file);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
// the readonly flag can/will be wrong, not anymore I think.
|
// 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;
|
return false;
|
||||||
buf = theBufferList().newBuffer(included_file);
|
buf = theBufferList().newBuffer(included_file);
|
||||||
if (!loadLyXFile(buf, included_file))
|
if (!loadLyXFile(buf, fullname))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (buf)
|
if (buf)
|
||||||
|
@ -103,7 +103,7 @@ bool quitting; // flag, that we are quitting the program
|
|||||||
bool menuWrite(Buffer * buffer)
|
bool menuWrite(Buffer * buffer)
|
||||||
{
|
{
|
||||||
if (buffer->save()) {
|
if (buffer->save()) {
|
||||||
LyX::ref().session().lastFiles().add(buffer->fileName());
|
LyX::ref().session().lastFiles().add(FileName(buffer->fileName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ int LyX::exec(int & argc, char * argv[])
|
|||||||
support::init_package(argv[0], cl_system_support, cl_user_support,
|
support::init_package(argv[0], cl_system_support, cl_user_support,
|
||||||
support::top_build_dir_is_one_level_up);
|
support::top_build_dir_is_one_level_up);
|
||||||
|
|
||||||
vector<string> files;
|
vector<FileName> files;
|
||||||
|
|
||||||
if (!use_gui) {
|
if (!use_gui) {
|
||||||
// FIXME: create a ConsoleApplication
|
// FIXME: create a ConsoleApplication
|
||||||
@ -472,7 +472,7 @@ void LyX::quit()
|
|||||||
|
|
||||||
|
|
||||||
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
|
// check for any spurious extra arguments
|
||||||
// other than documents
|
// other than documents
|
||||||
@ -498,28 +498,27 @@ int LyX::loadFiles(int & argc, char * argv[],
|
|||||||
// frontend.
|
// frontend.
|
||||||
if (argv[argi][0] == '-')
|
if (argv[argi][0] == '-')
|
||||||
continue;
|
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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first_start)
|
if (first_start)
|
||||||
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<FileName>::const_iterator it = files.begin();
|
||||||
vector<string>::const_iterator end = files.end();
|
vector<FileName>::const_iterator end = files.end();
|
||||||
|
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
// get absolute path of file and add ".lyx" to
|
if (it->empty()) {
|
||||||
// the filename if necessary
|
Buffer * const b = newFile(it->absFilename(), string(), true);
|
||||||
string s = fileSearch(string(), *it, "lyx").absFilename();
|
|
||||||
if (s.empty()) {
|
|
||||||
Buffer * const b = newFile(*it, string(), true);
|
|
||||||
if (b)
|
if (b)
|
||||||
last_loaded = b;
|
last_loaded = b;
|
||||||
} else {
|
} else {
|
||||||
Buffer * buf = pimpl_->buffer_list_.newBuffer(s, false);
|
Buffer * buf = pimpl_->buffer_list_.newBuffer(it->absFilename(), false);
|
||||||
if (loadLyXFile(buf, s)) {
|
if (loadLyXFile(buf, *it)) {
|
||||||
last_loaded = buf;
|
last_loaded = buf;
|
||||||
ErrorList const & el = buf->errorList("Parse");
|
ErrorList const & el = buf->errorList("Parse");
|
||||||
if (!el.empty())
|
if (!el.empty())
|
||||||
@ -550,7 +549,7 @@ void LyX::execBatchCommands()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyX::restoreGuiSession(vector<string> const & files)
|
void LyX::restoreGuiSession(vector<FileName> const & files)
|
||||||
{
|
{
|
||||||
LyXView * view = newLyXView();
|
LyXView * view = newLyXView();
|
||||||
|
|
||||||
@ -560,7 +559,7 @@ void LyX::restoreGuiSession(vector<string> const & files)
|
|||||||
|
|
||||||
// if a file is specified, I assume that user wants to edit *that* file
|
// if a file is specified, I assume that user wants to edit *that* file
|
||||||
if (files.empty() && lyxrc.load_session) {
|
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
|
// do not add to the lastfile list since these files are restored from
|
||||||
// last seesion, and should be already there (regular files), or should
|
// last seesion, and should be already there (regular files), or should
|
||||||
// not be added at all (help files).
|
// not be added at all (help files).
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#ifndef LYX_MAIN_H
|
#ifndef LYX_MAIN_H
|
||||||
#define LYX_MAIN_H
|
#define LYX_MAIN_H
|
||||||
|
|
||||||
|
#include "support/filename.h"
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
@ -121,10 +123,10 @@ private:
|
|||||||
\return exit code failure if any.
|
\return exit code failure if any.
|
||||||
*/
|
*/
|
||||||
int loadFiles(int & argc, char * argv[],
|
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.
|
/// Initialize RC font for the GUI.
|
||||||
void initGuiFont();
|
void initGuiFont();
|
||||||
|
@ -1045,7 +1045,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
// might be visible in more than one LyXView.
|
// might be visible in more than one LyXView.
|
||||||
if (lyx_view_ && lyx_view_->view()->buffer()) {
|
if (lyx_view_ && lyx_view_->view()->buffer()) {
|
||||||
// save cursor Position for opened files to .lyx/session
|
// 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()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1076,14 +1076,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
setErrorMessage(_("Missing argument"));
|
setErrorMessage(_("Missing argument"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
string const fname = i18nLibFileSearch("doc", arg, "lyx").absFilename();
|
FileName const fname = i18nLibFileSearch("doc", arg, "lyx");
|
||||||
if (fname.empty()) {
|
if (fname.empty()) {
|
||||||
lyxerr << "LyX: unable to find documentation file `"
|
lyxerr << "LyX: unable to find documentation file `"
|
||||||
<< arg << "'. Bad installation?" << endl;
|
<< arg << "'. Bad installation?" << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lyx_view_->message(bformat(_("Opening help file %1$s..."),
|
lyx_view_->message(bformat(_("Opening help file %1$s..."),
|
||||||
makeDisplayPath(fname)));
|
makeDisplayPath(fname.absFilename())));
|
||||||
lyx_view_->loadLyXFile(fname, false);
|
lyx_view_->loadLyXFile(fname, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1196,10 +1196,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
} else {
|
} else {
|
||||||
// Must replace extension of the file to be .lyx
|
// Must replace extension of the file to be .lyx
|
||||||
// and get full path
|
// 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)) {
|
if (theBufferList().exists(s.absFilename())) {
|
||||||
lyx_view_->setBuffer(theBufferList().getBuffer(s));
|
lyx_view_->setBuffer(theBufferList().getBuffer(s.absFilename()));
|
||||||
} else {
|
} else {
|
||||||
lyx_view_->loadLyXFile(s);
|
lyx_view_->loadLyXFile(s);
|
||||||
}
|
}
|
||||||
@ -1359,7 +1359,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
if (theBufferList().exists(filename))
|
if (theBufferList().exists(filename))
|
||||||
lyx_view_->setBuffer(theBufferList().getBuffer(filename));
|
lyx_view_->setBuffer(theBufferList().getBuffer(filename));
|
||||||
else
|
else
|
||||||
lyx_view_->loadLyXFile(filename);
|
lyx_view_->loadLyXFile(FileName(filename));
|
||||||
// Set the parent name of the child document.
|
// Set the parent name of the child document.
|
||||||
// This makes insertion of citations and references in the child work,
|
// This makes insertion of citations and references in the child work,
|
||||||
// when the target is in the parent or another child document.
|
// when the target is in the parent or another child document.
|
||||||
@ -1678,15 +1678,16 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
unsigned int idx = convert<unsigned int>(to_utf8(cmd.argument()));
|
unsigned int idx = convert<unsigned int>(to_utf8(cmd.argument()));
|
||||||
BookmarksSection::Bookmark const bm = LyX::ref().session().bookmarks().bookmark(idx);
|
BookmarksSection::Bookmark const bm = LyX::ref().session().bookmarks().bookmark(idx);
|
||||||
BOOST_ASSERT(!bm.filename.empty());
|
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))
|
if (!theBufferList().exists(file))
|
||||||
dispatch(FuncRequest(LFUN_FILE_OPEN, bm.filename));
|
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)
|
if (lyx_view_->buffer()->fileName() != file)
|
||||||
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, bm.filename));
|
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
|
||||||
// BOOST_ASSERT(lyx_view_->buffer()->fileName() != bm.filename);
|
// BOOST_ASSERT(lyx_view_->buffer()->fileName() != file);
|
||||||
view()->moveToPosition(bm.par_id, bm.par_pos);
|
view()->moveToPosition(bm.par_id, bm.par_pos);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1795,6 +1796,7 @@ void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd
|
|||||||
|
|
||||||
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 initpath = lyxrc.document_path;
|
||||||
string filename(name);
|
string filename(name);
|
||||||
|
|
||||||
@ -1884,11 +1886,9 @@ void LyXFunc::open(string const & fname)
|
|||||||
// get absolute path of file and add ".lyx" to the filename if
|
// get absolute path of file and add ".lyx" to the filename if
|
||||||
// necessary
|
// necessary
|
||||||
FileName const fullname = fileSearch(string(), filename, "lyx");
|
FileName const fullname = fileSearch(string(), filename, "lyx");
|
||||||
BOOST_ASSERT(!fullname.empty());
|
if (!fullname.empty())
|
||||||
filename = fullname.absFilename();
|
filename = fullname.absFilename();
|
||||||
|
|
||||||
docstring const disp_fn = makeDisplayPath(filename);
|
|
||||||
|
|
||||||
// if the file doesn't exist, let the user create one
|
// if the file doesn't exist, let the user create one
|
||||||
if (!fs::exists(fullname.toFilesystemEncoding())) {
|
if (!fs::exists(fullname.toFilesystemEncoding())) {
|
||||||
// the user specifically chose this name. Believe him.
|
// the user specifically chose this name. Believe him.
|
||||||
@ -1898,10 +1898,11 @@ void LyXFunc::open(string const & fname)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
docstring const disp_fn = makeDisplayPath(filename);
|
||||||
lyx_view_->message(bformat(_("Opening document %1$s..."), disp_fn));
|
lyx_view_->message(bformat(_("Opening document %1$s..."), disp_fn));
|
||||||
|
|
||||||
docstring str2;
|
docstring str2;
|
||||||
if (lyx_view_->loadLyXFile(filename)) {
|
if (lyx_view_->loadLyXFile(fullname)) {
|
||||||
str2 = bformat(_("Document %1$s opened."), disp_fn);
|
str2 = bformat(_("Document %1$s opened."), disp_fn);
|
||||||
} else {
|
} else {
|
||||||
str2 = bformat(_("Could not open document %1$s"), disp_fn);
|
str2 = bformat(_("Could not open document %1$s"), disp_fn);
|
||||||
@ -1963,13 +1964,13 @@ void LyXFunc::doImport(string const & argument)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// get absolute path of file
|
// 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 (use_gui && theBufferList().exists(lyxfile.absFilename())) {
|
||||||
if (!theBufferList().close(theBufferList().getBuffer(lyxfile), true)) {
|
if (!theBufferList().close(theBufferList().getBuffer(lyxfile.absFilename()), true)) {
|
||||||
lyx_view_->message(_("Canceled."));
|
lyx_view_->message(_("Canceled."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1977,8 +1978,8 @@ void LyXFunc::doImport(string const & argument)
|
|||||||
|
|
||||||
// if the file exists already, and we didn't do
|
// if the file exists already, and we didn't do
|
||||||
// -i lyx thefile.lyx, warn
|
// -i lyx thefile.lyx, warn
|
||||||
if (fs::exists(lyxfile) && filename != lyxfile) {
|
if (fs::exists(lyxfile.toFilesystemEncoding()) && fullname != lyxfile) {
|
||||||
docstring const file = makeDisplayPath(lyxfile, 30);
|
docstring const file = makeDisplayPath(lyxfile.absFilename(), 30);
|
||||||
|
|
||||||
docstring text = bformat(_("The document %1$s already exists.\n\n"
|
docstring text = bformat(_("The document %1$s already exists.\n\n"
|
||||||
"Do you want to over-write that document?"), file);
|
"Do you want to over-write that document?"), file);
|
||||||
@ -1992,7 +1993,7 @@ void LyXFunc::doImport(string const & argument)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ErrorList errorList;
|
ErrorList errorList;
|
||||||
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?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2000,7 +2001,7 @@ void LyXFunc::doImport(string const & argument)
|
|||||||
void LyXFunc::closeBuffer()
|
void LyXFunc::closeBuffer()
|
||||||
{
|
{
|
||||||
// save current cursor position
|
// 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()) );
|
boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
|
||||||
if (theBufferList().close(lyx_view_->buffer(), true) && !quitting) {
|
if (theBufferList().close(lyx_view_->buffer(), true) && !quitting) {
|
||||||
if (theBufferList().empty()) {
|
if (theBufferList().empty()) {
|
||||||
|
22
src/lyxvc.C
22
src/lyxvc.C
@ -54,9 +54,9 @@ LyXVC::~LyXVC()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
bool LyXVC::file_found_hook(string const & fn)
|
bool LyXVC::file_found_hook(FileName const & fn)
|
||||||
{
|
{
|
||||||
string found_file;
|
FileName found_file;
|
||||||
// Check if file is under RCS
|
// Check if file is under RCS
|
||||||
if (!(found_file = RCS::find_file(fn)).empty()) {
|
if (!(found_file = RCS::find_file(fn)).empty()) {
|
||||||
vcs.reset(new RCS(found_file));
|
vcs.reset(new RCS(found_file));
|
||||||
@ -74,7 +74,7 @@ bool LyXVC::file_found_hook(string const & fn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyXVC::file_not_found_hook(string const & fn)
|
bool LyXVC::file_not_found_hook(FileName const & fn)
|
||||||
{
|
{
|
||||||
// Check if file is under RCS
|
// Check if file is under RCS
|
||||||
if (!RCS::find_file(fn).empty())
|
if (!RCS::find_file(fn).empty())
|
||||||
@ -93,10 +93,10 @@ void LyXVC::buffer(Buffer * buf)
|
|||||||
|
|
||||||
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"),
|
Alert::error(_("Document not saved"),
|
||||||
_("You must save the document "
|
_("You must save the document "
|
||||||
"before it can be registered."));
|
"before it can be registered."));
|
||||||
@ -105,19 +105,19 @@ void LyXVC::registrer()
|
|||||||
|
|
||||||
// it is very likely here that the vcs is not created yet...
|
// it is very likely here that the vcs is not created yet...
|
||||||
if (!vcs) {
|
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]
|
lyxerr[Debug::LYXVC]
|
||||||
<< "LyXVC: registering "
|
<< "LyXVC: registering "
|
||||||
<< to_utf8(makeDisplayPath(filename))
|
<< to_utf8(makeDisplayPath(filename.absFilename()))
|
||||||
<< " with CVS" << endl;
|
<< " with CVS" << endl;
|
||||||
vcs.reset(new CVS(cvs_entries, filename));
|
vcs.reset(new CVS(cvs_entries, filename));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
lyxerr[Debug::LYXVC]
|
lyxerr[Debug::LYXVC]
|
||||||
<< "LyXVC: registering "
|
<< "LyXVC: registering "
|
||||||
<< to_utf8(makeDisplayPath(filename))
|
<< to_utf8(makeDisplayPath(filename.absFilename()))
|
||||||
<< " with RCS" << endl;
|
<< " with RCS" << endl;
|
||||||
vcs.reset(new RCS(filename));
|
vcs.reset(new RCS(filename));
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ string const LyXVC::getLogFile() const
|
|||||||
if (!vcs)
|
if (!vcs)
|
||||||
return string();
|
return string();
|
||||||
|
|
||||||
string tmpf = tempName(string(), "lyxvclog");
|
FileName const tmpf(tempName(string(), "lyxvclog"));
|
||||||
if (tmpf.empty()) {
|
if (tmpf.empty()) {
|
||||||
lyxerr[Debug::LYXVC] << "Could not generate logfile "
|
lyxerr[Debug::LYXVC] << "Could not generate logfile "
|
||||||
<< tmpf << endl;
|
<< tmpf << endl;
|
||||||
@ -237,7 +237,7 @@ string const LyXVC::getLogFile() const
|
|||||||
}
|
}
|
||||||
lyxerr[Debug::LYXVC] << "Generating logfile " << tmpf << endl;
|
lyxerr[Debug::LYXVC] << "Generating logfile " << tmpf << endl;
|
||||||
vcs->getLog(tmpf);
|
vcs->getLog(tmpf);
|
||||||
return tmpf;
|
return tmpf.absFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
namespace support { class FileName; }
|
||||||
|
|
||||||
class VCS;
|
class VCS;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
@ -50,7 +51,7 @@ public:
|
|||||||
the appropiate actions is taken. Returns true if the file is under
|
the appropiate actions is taken. Returns true if the file is under
|
||||||
control by a VCS.
|
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,
|
/** 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
|
but it does not exist. This function will then check for a VC master
|
||||||
@ -59,7 +60,7 @@ public:
|
|||||||
viewing/editing. Returns true if the file is under control by a VCS
|
viewing/editing. Returns true if the file is under control by a VCS
|
||||||
and the user wants to view/edit it.
|
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 *);
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
using lyx::support::absolutePath;
|
||||||
using lyx::support::addName;
|
using lyx::support::addName;
|
||||||
|
using lyx::support::FileName;
|
||||||
using lyx::support::package;
|
using lyx::support::package;
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
@ -71,12 +73,15 @@ void LastFilesSection::read(istream & is)
|
|||||||
if (c == '[')
|
if (c == '[')
|
||||||
break;
|
break;
|
||||||
getline(is, tmp);
|
getline(is, tmp);
|
||||||
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ')
|
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ' || !absolutePath(tmp))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// read lastfiles
|
// read lastfiles
|
||||||
if (fs::exists(tmp) && !fs::is_directory(tmp) && lastfiles.size() < num_lastfiles)
|
FileName const file(tmp);
|
||||||
lastfiles.push_back(tmp);
|
if (fs::exists(file.toFilesystemEncoding()) &&
|
||||||
|
!fs::is_directory(file.toFilesystemEncoding()) &&
|
||||||
|
lastfiles.size() < num_lastfiles)
|
||||||
|
lastfiles.push_back(file);
|
||||||
else
|
else
|
||||||
lyxerr[Debug::INIT] << "LyX: Warning: Ignore last file: " << tmp << endl;
|
lyxerr[Debug::INIT] << "LyX: Warning: Ignore last file: " << tmp << endl;
|
||||||
} while (is.good());
|
} while (is.good());
|
||||||
@ -87,11 +92,11 @@ void LastFilesSection::write(ostream & os) const
|
|||||||
{
|
{
|
||||||
os << '\n' << sec_lastfiles << '\n';
|
os << '\n' << sec_lastfiles << '\n';
|
||||||
copy(lastfiles.begin(), lastfiles.end(),
|
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.
|
// If file already exist, delete it and reinsert at front.
|
||||||
LastFiles::iterator it = find(lastfiles.begin(), lastfiles.end(), file);
|
LastFiles::iterator it = find(lastfiles.begin(), lastfiles.end(), file);
|
||||||
@ -124,11 +129,13 @@ void LastOpenedSection::read(istream & is)
|
|||||||
if (c == '[')
|
if (c == '[')
|
||||||
break;
|
break;
|
||||||
getline(is, tmp);
|
getline(is, tmp);
|
||||||
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ')
|
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ' || !absolutePath(tmp))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fs::exists(tmp) && !fs::is_directory(tmp))
|
FileName const file(tmp);
|
||||||
lastopened.push_back(tmp);
|
if (fs::exists(file.toFilesystemEncoding()) &&
|
||||||
|
!fs::is_directory(file.toFilesystemEncoding()))
|
||||||
|
lastopened.push_back(file);
|
||||||
else
|
else
|
||||||
lyxerr[Debug::INIT] << "LyX: Warning: Ignore last opened file: " << tmp << endl;
|
lyxerr[Debug::INIT] << "LyX: Warning: Ignore last opened file: " << tmp << endl;
|
||||||
} while (is.good());
|
} while (is.good());
|
||||||
@ -139,11 +146,11 @@ void LastOpenedSection::write(ostream & os) const
|
|||||||
{
|
{
|
||||||
os << '\n' << sec_lastopened << '\n';
|
os << '\n' << sec_lastopened << '\n';
|
||||||
copy(lastopened.begin(), lastopened.end(),
|
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);
|
||||||
}
|
}
|
||||||
@ -178,8 +185,13 @@ void LastFilePosSection::read(istream & is)
|
|||||||
itmp >> pos;
|
itmp >> pos;
|
||||||
itmp.ignore(2); // ignore ", "
|
itmp.ignore(2); // ignore ", "
|
||||||
itmp >> fname;
|
itmp >> fname;
|
||||||
if (fs::exists(fname) && !fs::is_directory(fname) && lastfilepos.size() < num_lastfilepos)
|
if (!absolutePath(fname))
|
||||||
lastfilepos[fname] = boost::tie(pit, pos);
|
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
|
else
|
||||||
lyxerr[Debug::INIT] << "LyX: Warning: Ignore pos of last file: " << fname << endl;
|
lyxerr[Debug::INIT] << "LyX: Warning: Ignore pos of last file: " << fname << endl;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@ -201,13 +213,13 @@ void LastFilePosSection::write(ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
FilePosMap::const_iterator entry = lastfilepos.find(fname);
|
||||||
// Has position information, return it.
|
// Has position information, return it.
|
||||||
@ -242,9 +254,14 @@ void BookmarksSection::read(istream & is)
|
|||||||
itmp >> pos;
|
itmp >> pos;
|
||||||
itmp.ignore(2); // ignore ", "
|
itmp.ignore(2); // ignore ", "
|
||||||
itmp >> fname;
|
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)
|
if (fs::exists(file.toFilesystemEncoding()) &&
|
||||||
bookmarks.push_back(Bookmark(fname, id, pos));
|
!fs::is_directory(file.toFilesystemEncoding()) &&
|
||||||
|
bookmarks.size() < max_bookmarks)
|
||||||
|
bookmarks.push_back(Bookmark(file, id, pos));
|
||||||
else
|
else
|
||||||
lyxerr[Debug::INIT] << "LyX: Warning: Ignore bookmark of file: " << fname << endl;
|
lyxerr[Debug::INIT] << "LyX: Warning: Ignore bookmark of file: " << fname << endl;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@ -265,7 +282,7 @@ void BookmarksSection::write(ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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) {
|
if (persistent) {
|
||||||
bookmarks.push_front(Bookmark(fname, par_id, par_pos));
|
bookmarks.push_front(Bookmark(fname, par_id, par_pos));
|
||||||
@ -407,7 +424,7 @@ Session::Session(unsigned int num) :
|
|||||||
{
|
{
|
||||||
// locate the session file
|
// locate the session file
|
||||||
// note that the session file name 'session' is hard-coded
|
// 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"));
|
||||||
//
|
//
|
||||||
readFile();
|
readFile();
|
||||||
}
|
}
|
||||||
@ -417,7 +434,7 @@ void Session::readFile()
|
|||||||
{
|
{
|
||||||
// we will not complain if we can't find session_file nor will
|
// we will not complain if we can't find session_file nor will
|
||||||
// we issue a warning. (Lgb)
|
// we issue a warning. (Lgb)
|
||||||
ifstream is(session_file.c_str());
|
ifstream is(session_file.toFilesystemEncoding().c_str());
|
||||||
string tmp;
|
string tmp;
|
||||||
|
|
||||||
while (getline(is, tmp)) {
|
while (getline(is, tmp)) {
|
||||||
@ -446,7 +463,7 @@ void Session::readFile()
|
|||||||
|
|
||||||
void Session::writeFile() const
|
void Session::writeFile() const
|
||||||
{
|
{
|
||||||
ofstream os(session_file.c_str());
|
ofstream os(session_file.toFilesystemEncoding().c_str());
|
||||||
if (os) {
|
if (os) {
|
||||||
os << "## Automatically generated lyx session file \n"
|
os << "## Automatically generated lyx session file \n"
|
||||||
<< "## Editing this file manually may cause lyx to crash.\n";
|
<< "## Editing this file manually may cause lyx to crash.\n";
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
#ifndef SESSION_H
|
#ifndef SESSION_H
|
||||||
#define SESSION_H
|
#define SESSION_H
|
||||||
|
|
||||||
#include <support/types.h>
|
#include "support/filename.h"
|
||||||
|
#include "support/types.h"
|
||||||
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
@ -55,7 +56,7 @@ class LastFilesSection : SessionSection
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
typedef std::deque<std::string> LastFiles;
|
typedef std::deque<support::FileName> LastFiles;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -77,7 +78,7 @@ public:
|
|||||||
file in the list is popped from the end.
|
file in the list is popped from the end.
|
||||||
@param file the file to insert in the lastfile list.
|
@param file the file to insert in the lastfile list.
|
||||||
*/
|
*/
|
||||||
void add(std::string const & file);
|
void add(support::FileName const & file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Default number of lastfiles.
|
/// Default number of lastfiles.
|
||||||
@ -103,7 +104,7 @@ class LastOpenedSection : SessionSection
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
typedef std::vector<std::string> LastOpened;
|
typedef std::vector<support::FileName> LastOpened;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -118,7 +119,7 @@ public:
|
|||||||
/** add file to lastopened file list
|
/** add file to lastopened file list
|
||||||
@param file filename to add
|
@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
|
||||||
*/
|
*/
|
||||||
@ -137,7 +138,7 @@ public:
|
|||||||
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;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -153,12 +154,12 @@ public:
|
|||||||
@param fname file entry for which to save position information
|
@param fname file entry for which to save position information
|
||||||
@param pos position of the cursor when the file is closed.
|
@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
|
/** load saved cursor position from the fname entry in the filepos map
|
||||||
@param fname file entry for which to load position information
|
@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:
|
private:
|
||||||
/// default number of lastfilepos to save */
|
/// default number of lastfilepos to save */
|
||||||
@ -177,7 +178,7 @@ public:
|
|||||||
class Bookmark {
|
class Bookmark {
|
||||||
public:
|
public:
|
||||||
/// Filename
|
/// Filename
|
||||||
std::string filename;
|
support::FileName filename;
|
||||||
/// Cursor paragraph Id
|
/// Cursor paragraph Id
|
||||||
int par_id;
|
int par_id;
|
||||||
/// Cursor position
|
/// Cursor position
|
||||||
@ -185,7 +186,7 @@ public:
|
|||||||
///
|
///
|
||||||
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) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ public:
|
|||||||
|
|
||||||
/// Save the current position as bookmark
|
/// Save the current position as bookmark
|
||||||
/// if save==false, save to temp_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
|
/// return bookmark, return temp_bookmark if i==0
|
||||||
Bookmark const & bookmark(unsigned int i) const;
|
Bookmark const & bookmark(unsigned int i) const;
|
||||||
@ -379,7 +380,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// file to save session, determined in the constructor.
|
/// file to save session, determined in the constructor.
|
||||||
std::string session_file;
|
support::FileName session_file;
|
||||||
|
|
||||||
/** Read the session file.
|
/** Read the session file.
|
||||||
Reads the #.lyx/session# at the beginning of the LyX session.
|
Reads the #.lyx/session# at the beginning of the LyX session.
|
||||||
|
@ -31,6 +31,7 @@ namespace lyx {
|
|||||||
using support::addName;
|
using support::addName;
|
||||||
using support::addPath;
|
using support::addPath;
|
||||||
using support::contains;
|
using support::contains;
|
||||||
|
using support::FileName;
|
||||||
using support::onlyFilename;
|
using support::onlyFilename;
|
||||||
using support::onlyPath;
|
using support::onlyPath;
|
||||||
using support::quoteName;
|
using support::quoteName;
|
||||||
@ -65,44 +66,42 @@ int VCS::doVCCommand(string const & cmd, string const & path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RCS::RCS(string const & m)
|
RCS::RCS(FileName const & m)
|
||||||
{
|
{
|
||||||
master_ = m;
|
master_ = m;
|
||||||
scanMaster();
|
scanMaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const RCS::find_file(string const & file)
|
FileName const RCS::find_file(FileName const & file)
|
||||||
{
|
{
|
||||||
string tmp = file;
|
|
||||||
// Check if *,v exists.
|
// Check if *,v exists.
|
||||||
tmp += ",v";
|
FileName tmp(file.absFilename() + ",v");
|
||||||
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
|
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
|
||||||
<< tmp << endl;
|
<< tmp << endl;
|
||||||
if (fs::is_readable(tmp)) {
|
if (fs::is_readable(tmp.toFilesystemEncoding())) {
|
||||||
lyxerr[Debug::LYXVC] << "Yes " << file
|
lyxerr[Debug::LYXVC] << "Yes " << file
|
||||||
<< " is under rcs." << endl;
|
<< " is under rcs." << endl;
|
||||||
return tmp;
|
return tmp;
|
||||||
} else {
|
} else {
|
||||||
// Check if RCS/*,v exists.
|
// Check if RCS/*,v exists.
|
||||||
tmp = addName(addPath(onlyPath(file), "RCS"), file);
|
tmp = FileName(addName(addPath(onlyPath(file.absFilename()), "RCS"), file.absFilename()) + ",v");
|
||||||
tmp += ",v";
|
|
||||||
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
|
lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
|
||||||
<< tmp << endl;
|
<< tmp << endl;
|
||||||
if (fs::is_readable(tmp)) {
|
if (fs::is_readable(tmp.toFilesystemEncoding())) {
|
||||||
lyxerr[Debug::LYXVC] << "Yes " << file
|
lyxerr[Debug::LYXVC] << "Yes " << file
|
||||||
<< " it is under rcs."<< endl;
|
<< " it is under rcs."<< endl;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string();
|
return FileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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()),
|
||||||
string());
|
string());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ void RCS::scanMaster()
|
|||||||
{
|
{
|
||||||
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;
|
string token;
|
||||||
bool read_enough = false;
|
bool read_enough = false;
|
||||||
@ -216,15 +215,15 @@ void RCS::undoLast()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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,
|
+ " > " + tmpf.toFilesystemEncoding(),
|
||||||
owner_->filePath());
|
owner_->filePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CVS::CVS(string const & m, string const & f)
|
CVS::CVS(FileName const & m, FileName const & f)
|
||||||
{
|
{
|
||||||
master_ = m;
|
master_ = m;
|
||||||
file_ = f;
|
file_ = f;
|
||||||
@ -232,26 +231,27 @@ CVS::CVS(string const & m, string const & 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
|
// First we look for the CVS/Entries in the same dir
|
||||||
// where we have file.
|
// where we have file.
|
||||||
string const dir = onlyPath(file) + "/CVS/Entries";
|
FileName const dir(onlyPath(file.absFilename()) + "/CVS/Entries");
|
||||||
string const tmpf = "/" + onlyFilename(file) + "/";
|
string const tmpf = '/' + onlyFilename(file.absFilename()) + '/';
|
||||||
lyxerr[Debug::LYXVC] << "LyXVC: checking in `" << dir
|
lyxerr[Debug::LYXVC] << "LyXVC: checking in `" << dir
|
||||||
<< "' for `" << tmpf << '\'' << endl;
|
<< "' 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
|
// 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
|
// and see if we can find this file. We do a fast and
|
||||||
// dirty parse here.
|
// dirty parse here.
|
||||||
ifstream ifs(dir.c_str());
|
ifstream ifs(dir.toFilesystemEncoding().c_str());
|
||||||
string line;
|
string line;
|
||||||
while (getline(ifs, line)) {
|
while (getline(ifs, line)) {
|
||||||
lyxerr[Debug::LYXVC] << "\tEntries: " << line << endl;
|
lyxerr[Debug::LYXVC] << "\tEntries: " << line << endl;
|
||||||
if (contains(line, tmpf)) return dir;
|
if (contains(line, tmpf))
|
||||||
|
return dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string();
|
return FileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -260,8 +260,8 @@ void CVS::scanMaster()
|
|||||||
lyxerr[Debug::LYXVC] << "LyXVC::CVS: scanMaster. \n Checking: "
|
lyxerr[Debug::LYXVC] << "LyXVC::CVS: scanMaster. \n Checking: "
|
||||||
<< master_ << endl;
|
<< master_ << endl;
|
||||||
// Ok now we do the real scan...
|
// Ok now we do the real scan...
|
||||||
ifstream ifs(master_.c_str());
|
ifstream ifs(master_.toFilesystemEncoding().c_str());
|
||||||
string tmpf = "/" + onlyFilename(file_) + "/";
|
string tmpf = '/' + onlyFilename(file_.absFilename()) + '/';
|
||||||
lyxerr[Debug::LYXVC] << "\tlooking for `" << tmpf << '\'' << endl;
|
lyxerr[Debug::LYXVC] << "\tlooking for `" << tmpf << '\'' << endl;
|
||||||
string line;
|
string line;
|
||||||
static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
|
static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
|
||||||
@ -281,7 +281,7 @@ void CVS::scanMaster()
|
|||||||
//sm[4]; // options
|
//sm[4]; // options
|
||||||
//sm[5]; // tag or tagdate
|
//sm[5]; // tag or tagdate
|
||||||
// FIXME: must double check file is stattable/existing
|
// 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");
|
string mod_date = rtrim(asctime(gmtime(&mod)), "\n");
|
||||||
lyxerr[Debug::LYXVC]
|
lyxerr[Debug::LYXVC]
|
||||||
<< "Date in Entries: `" << file_date
|
<< "Date in Entries: `" << file_date
|
||||||
@ -346,10 +346,10 @@ void CVS::undoLast()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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,
|
+ " > " + tmpf.toFilesystemEncoding(),
|
||||||
owner_->filePath());
|
owner_->filePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#ifndef VC_BACKEND_H
|
#ifndef VC_BACKEND_H
|
||||||
#define VC_BACKEND_H
|
#define VC_BACKEND_H
|
||||||
|
|
||||||
|
#include "support/filename.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +46,7 @@ public:
|
|||||||
* getLog - read the revision log into the given file
|
* getLog - read the revision log into the given file
|
||||||
* @param fname file name to read into
|
* @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
|
/// return the current version description
|
||||||
virtual std::string const versionString() const = 0;
|
virtual std::string const versionString() const = 0;
|
||||||
/// return the current version
|
/// return the current version
|
||||||
@ -75,7 +77,7 @@ protected:
|
|||||||
* The master VC file. For RCS this is *,v or RCS/ *,v. master should
|
* The master VC file. For RCS this is *,v or RCS/ *,v. master should
|
||||||
* have full path.
|
* have full path.
|
||||||
*/
|
*/
|
||||||
std::string master_;
|
support::FileName master_;
|
||||||
|
|
||||||
/// The status of the VC controlled file.
|
/// The status of the VC controlled file.
|
||||||
VCStatus vcstatus;
|
VCStatus vcstatus;
|
||||||
@ -98,12 +100,12 @@ class RCS : public VCS {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
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);
|
||||||
|
|
||||||
@ -115,7 +117,7 @@ public:
|
|||||||
|
|
||||||
virtual void undoLast();
|
virtual void undoLast();
|
||||||
|
|
||||||
virtual void getLog(std::string const &);
|
virtual void getLog(support::FileName const &);
|
||||||
|
|
||||||
virtual std::string const versionString() const {
|
virtual std::string const versionString() const {
|
||||||
return "RCS: " + version_;
|
return "RCS: " + version_;
|
||||||
@ -131,10 +133,10 @@ class CVS : public VCS {
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
explicit
|
explicit
|
||||||
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);
|
||||||
|
|
||||||
@ -146,7 +148,7 @@ public:
|
|||||||
|
|
||||||
virtual void undoLast();
|
virtual void undoLast();
|
||||||
|
|
||||||
virtual void getLog(std::string const &);
|
virtual void getLog(support::FileName const &);
|
||||||
|
|
||||||
virtual std::string const versionString() const {
|
virtual std::string const versionString() const {
|
||||||
return "CVS: " + version_;
|
return "CVS: " + version_;
|
||||||
@ -156,7 +158,7 @@ protected:
|
|||||||
virtual void scanMaster();
|
virtual void scanMaster();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string file_;
|
support::FileName file_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
Loading…
Reference in New Issue
Block a user