+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
#include "lyx_cb.h"
#include "gettext.h"
#include "LyXView.h"
+#include "vc-backend.h"
extern BufferView * current_view;
extern int RunLinuxDoc(int, string const &);
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),
}
-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;
}
#include <config.h>
#include <cctype>
-#include <fstream>
-using std::fstream;
-using std::ios;
#include <utility>
using std::make_pair;
// -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.
}
#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;
}
}
+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;
cmd += "\" \"";
cmd += OnlyFilename(owner_->fileName());
cmd += "\"";
- doVCCommand(cmd);
+ doVCCommand(cmd, owner_->filepath);
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
}
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");
}
{
owner_->markLyxClean();
doVCCommand("co -q -l \""
- + OnlyFilename(owner_->fileName()) + "\"");
+ + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
}
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()
{
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);
}
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");
}
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");
}
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.
///
static string find_file(string const & file);
///
+ static void retrive(string const & file);
+ ///
virtual void scanMaster();
///
virtual void registrer(string const & msg);