mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-19 14:30:32 +00:00
fix IsFileWriteable, implement the file_not_found_hook and make it work for RCS
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@413 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e656d12d0b
commit
18b8221ede
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2000-01-11 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/vc-backend.C (doVCCommand): change to be static and take one
|
||||
more parameter: the path to chdir too be fore executing the command.
|
||||
(retrive): new function equiv to "co -r"
|
||||
|
||||
* src/bufferlist.C (loadLyXFile): implement the missing parts if
|
||||
file_not_found_hook is true.
|
||||
|
||||
* src/lyxvc.C (file_not_found_hook): implement file_not_found_hook.
|
||||
|
||||
* src/support/filetools.C (IsFileWriteable): use FileInfo to check
|
||||
if a file is readwrite,readonly...anything else.
|
||||
|
||||
2000-01-10 Lars Gullik Bjřnnes <larsbj@lyx.org>
|
||||
|
||||
* src/lyx_cb.C (MakeLaTeXOutput): name change from MakeDVIOutput
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "lyx_cb.h"
|
||||
#include "gettext.h"
|
||||
#include "LyXView.h"
|
||||
#include "vc-backend.h"
|
||||
|
||||
extern BufferView * current_view;
|
||||
extern int RunLinuxDoc(int, string const &);
|
||||
@ -596,7 +597,13 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
if (LyXVC::file_not_found_hook(s)) {
|
||||
// Ask if the file should be checked out for
|
||||
// viewing/editing, if so: load it.
|
||||
lyxerr << "Do you want to checkout?" << endl;
|
||||
if (AskQuestion(_("Do you want to retrive file under version control?"))) {
|
||||
// How can we know _how_ to do the checkout?
|
||||
// With the current VC support it has to be,
|
||||
// a RCS file since CVS do not have special ,v files.
|
||||
RCS::retrive(s);
|
||||
return loadLyXFile(filename, tolastfiles);
|
||||
}
|
||||
}
|
||||
if (AskQuestion(_("Cannot open specified file:"),
|
||||
MakeDisplayPath(s, 50),
|
||||
|
@ -59,9 +59,13 @@ bool LyXVC::file_found_hook(string const & fn)
|
||||
}
|
||||
|
||||
|
||||
bool LyXVC::file_not_found_hook(string const &)
|
||||
bool LyXVC::file_not_found_hook(string const & fn)
|
||||
{
|
||||
// file is not under any VCS.
|
||||
// Check if file is under RCS
|
||||
if (!RCS::find_file(fn).empty())
|
||||
return true;
|
||||
if (!CVS::find_file(fn).empty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,6 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <cctype>
|
||||
#include <fstream>
|
||||
using std::fstream;
|
||||
using std::ios;
|
||||
|
||||
#include <utility>
|
||||
using std::make_pair;
|
||||
@ -157,15 +154,12 @@ bool IsFileReadable (string const & path)
|
||||
// -1 error (doesn't exist, no access, anything else)
|
||||
int IsFileWriteable (string const & path)
|
||||
{
|
||||
fstream fs(path.c_str(), ios::out|ios::ate);
|
||||
if (!fs) {
|
||||
fs.open(path.c_str(), ios::in|ios::ate);
|
||||
if (fs)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
FileInfo fi(path);
|
||||
if (fi.access(FileInfo::wperm|FileInfo::rperm)) // read-write
|
||||
return 1;
|
||||
if (fi.readable()) // read-only
|
||||
return 0;
|
||||
return -1; // everything else.
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,11 +18,11 @@ using std::ifstream;
|
||||
#include "lyxfunc.h"
|
||||
|
||||
|
||||
int VCS::doVCCommand(string const & cmd)
|
||||
int VCS::doVCCommand(string const & cmd, string const & path)
|
||||
{
|
||||
lyxerr[Debug::LYXVC] << "doVCCommand: " << cmd << endl;
|
||||
Systemcalls one;
|
||||
Path p(owner_->filepath);
|
||||
Path p(path);
|
||||
int ret = one.startscript(Systemcalls::System, cmd);
|
||||
return ret;
|
||||
}
|
||||
@ -63,6 +63,15 @@ string RCS::find_file(string const & file)
|
||||
}
|
||||
|
||||
|
||||
void RCS::retrive(string const & file)
|
||||
{
|
||||
lyxerr[Debug::LYXVC] << "LyXVC::RCS: retrive.\n\t" << file << endl;
|
||||
VCS::doVCCommand("co -q -r \""
|
||||
+ file + "\"",
|
||||
string());
|
||||
}
|
||||
|
||||
|
||||
void RCS::scanMaster()
|
||||
{
|
||||
lyxerr[Debug::LYXVC] << "LyXVC::RCS: scanMaster." << endl;
|
||||
@ -133,7 +142,7 @@ void RCS::registrer(string const & msg)
|
||||
cmd += "\" \"";
|
||||
cmd += OnlyFilename(owner_->fileName());
|
||||
cmd += "\"";
|
||||
doVCCommand(cmd);
|
||||
doVCCommand(cmd, owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
|
||||
}
|
||||
|
||||
@ -141,7 +150,7 @@ void RCS::registrer(string const & msg)
|
||||
void RCS::checkIn(string const & msg)
|
||||
{
|
||||
doVCCommand("ci -q -u -m\"" + msg + "\" \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"");
|
||||
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
|
||||
}
|
||||
|
||||
@ -150,7 +159,7 @@ void RCS::checkOut()
|
||||
{
|
||||
owner_->markLyxClean();
|
||||
doVCCommand("co -q -l \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"");
|
||||
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
|
||||
}
|
||||
|
||||
@ -158,7 +167,7 @@ void RCS::checkOut()
|
||||
void RCS::revert()
|
||||
{
|
||||
doVCCommand("co -f -u" + version() + " \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"");
|
||||
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
|
||||
// We ignore changes and just reload!
|
||||
owner_->markLyxClean();
|
||||
owner_->getUser()->owner()
|
||||
@ -170,14 +179,14 @@ void RCS::undoLast()
|
||||
{
|
||||
lyxerr[Debug::LYXVC] << "LyXVC: undoLast" << endl;
|
||||
doVCCommand("rcs -o" + version() + " \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"");
|
||||
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
|
||||
}
|
||||
|
||||
|
||||
void RCS::getLog(string const & tmpf)
|
||||
{
|
||||
doVCCommand("rlog \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\" > " + tmpf);
|
||||
+ OnlyFilename(owner_->fileName()) + "\" > " + tmpf, owner_->filepath);
|
||||
}
|
||||
|
||||
|
||||
@ -263,7 +272,7 @@ void CVS::scanMaster()
|
||||
void CVS::registrer(string const & msg)
|
||||
{
|
||||
doVCCommand("cvs -q add -m \"" + msg + "\" \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"");
|
||||
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
|
||||
}
|
||||
|
||||
@ -271,7 +280,7 @@ void CVS::registrer(string const & msg)
|
||||
void CVS::checkIn(string const & msg)
|
||||
{
|
||||
doVCCommand("cvs -q commit -m \"" + msg + "\" \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"");
|
||||
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
VCStatus stat() const { return vcstat; }
|
||||
protected:
|
||||
///
|
||||
int doVCCommand(string const &);
|
||||
static int doVCCommand(string const &, string const &);
|
||||
|
||||
/** The master VC file. For RCS this is *,v or RCS/ *,v. master should
|
||||
have full path.
|
||||
@ -80,6 +80,8 @@ public:
|
||||
///
|
||||
static string find_file(string const & file);
|
||||
///
|
||||
static void retrive(string const & file);
|
||||
///
|
||||
virtual void scanMaster();
|
||||
///
|
||||
virtual void registrer(string const & msg);
|
||||
|
Loading…
Reference in New Issue
Block a user