#include "support/PathChanger.h"
#include "support/Systemcall.h"
#include "support/regex.h"
+#include "support/TempFile.h"
#include <fstream>
// if (getDiff(file, diff) && diff.empty())
// return false;
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return true;
FileName(owner_->filePath()));
docstring diff = tmpf.fileContents("UTF-8");
- tmpf.removeFile();
if (diff.empty())
return false;
bool RCS::getRevisionInfo()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;
if (!VCS::makeRCSRevision(version_, rev))
return false;
- FileName tmpf = FileName::tempName("lyxvcrev_" + rev + "_");
+ TempFile tempfile("lyxvcrev_" + rev + "_");
+ tempfile.setAutoRemove(false);
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;
CVS::CvsStatus CVS::getStatus()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return StatusError;
if (doVCCommandCallWithOutput("cvs status " + getTarget(File),
FileName(owner_->filePath()), tmpf)) {
- tmpf.removeFile();
return StatusError;
}
status = NeedsCheckout;
}
}
- tmpf.removeFile();
return status;
}
if (have_rev_info_)
return;
have_rev_info_ = true;
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return;
+ " " + getTarget(File),
FileName(owner_->filePath()), tmpf);
if (rc) {
- tmpf.removeFile();
LYXERR(Debug::LYXVC, "cvs log failed with exit code " << rc);
return;
}
break;
}
}
- tmpf.removeFile();
if (rev_author_cache_.empty())
LYXERR(Debug::LYXVC,
"Could not retrieve revision info for " << version_ <<
{
if (vcstatus != NOLOCKING && edit())
return string();
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return string();
rc = 0;
}
- tmpf.removeFile();
return rc ? string() : log.empty() ? "CVS: Proceeded" : "CVS: " + log;
}
string CVS::repoUpdate()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return string();
text, 0, 1, _("&Continue"), _("&Abort"));
hideDialogs("file", 0);
}
- if (ret == 1 ) {
- tmpf.removeFile();
+ if (ret == 1 )
return string();
- }
}
int rc = update(Directory, tmpf);
file, from_local8bit(sres)));
rc = 0;
}
-
- tmpf.removeFile();
return rc ? string() : log.empty() ? "CVS: Proceeded" : "CVS: " + log;
}
if (!VCS::makeRCSRevision(version_, rev))
return false;
- FileName tmpf = FileName::tempName("lyxvcrev_" + rev + "_");
+ TempFile tempfile("lyxvcrev_" + rev + "_");
+ tempfile.setAutoRemove(false);
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;
}
// Now we check the status of the file.
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return FileName();
bool found = 0 == doVCCommandCall("svn info " + quoteName(fname)
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
file.onlyPath());
- tmpf.removeFile();
LYXERR(Debug::LYXVC, "SVN control: " << (found ? "enabled" : "disabled"));
return found ? file : FileName();
}
bool SVN::checkLockMode()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()){
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;
LyXVC::CommandResult
SVN::checkIn(vector<support::FileName> const & f, string const & msg, string & log)
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()){
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
log = N_("Error: Could not generate logfile.");
if (!fileLock(false, tmpf, log))
ret = LyXVC::ErrorCommand;
- tmpf.removeFile();
if (!log.empty())
log.insert(0, "SVN: ");
if (ret == LyXVC::VCSuccess && log.empty())
{
// FIXME one day common getDiff and perhaps OpMode for all backends
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return true;
FileName(owner_->filePath()));
docstring diff = tmpf.fileContents("UTF-8");
- tmpf.removeFile();
if (diff.empty())
return false;
string SVN::checkOut()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return N_("Error: Could not generate logfile.");
fileLock(true, tmpf, log);
- tmpf.removeFile();
return log.empty() ? string() : "SVN: " + log;
}
string SVN::repoUpdate()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return N_("Error: Could not generate logfile.");
text, 0, 1, _("&Yes"), _("&No"));
hideDialogs("file", 0);
}
- if (ret == 1 ) {
- tmpf.removeFile();
+ if (ret == 1 )
return string();
- }
}
// Reverting looks too harsh, see bug #6255.
res += "Update log:\n" + tmpf.fileContents("UTF-8");
LYXERR(Debug::LYXVC, res);
- tmpf.removeFile();
return to_utf8(res);
}
string SVN::lockingToggle()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return N_("Error: Could not generate logfile.");
if (ret)
return string();
- tmpf.removeFile();
frontend::Alert::warning(_("SVN File Locking"),
(locking ? _("Locking property unset.") : _("Locking property set.")) + "\n"
+ _("Do not forget to commit the locking property into the repository."),
bool SVN::getFileRevisionInfo()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;
}
ifs.close();
- tmpf.removeFile();
return !rev.empty();
}
bool SVN::getTreeRevisionInfo()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;
string line;
getline(ifs, line);
ifs.close();
- tmpf.removeFile();
rev_tree_cache_ = line;
return !line.empty();
}
string revname = convert<string>(rev);
- FileName tmpf = FileName::tempName("lyxvcrev_" + revname + "_");
+ TempFile tempfile("lyxvcrev_" + revname + "_");
+ tempfile.setAutoRemove(false);
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;
}
// Now we check the status of the file.
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return FileName();
quoteName(tmpf.toFilesystemEncoding()),
file.onlyPath());
bool found = !tmpf.isFileEmpty();
- tmpf.removeFile();
LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : "disabled"));
return found ? file : FileName();
}
LyXVC::CommandResult
GIT::checkIn(vector<support::FileName> const & f, string const & msg, string & log)
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()){
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
log = N_("Error: Could not generate logfile.");
ret = LyXVC::ErrorCommand;
}
- tmpf.removeFile();
if (!log.empty())
log.insert(0, "GIT: ");
if (ret == LyXVC::VCSuccess && log.empty())
{
// FIXME one day common getDiff and perhaps OpMode for all backends
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return true;
FileName(owner_->filePath()));
docstring diff = tmpf.fileContents("UTF-8");
- tmpf.removeFile();
if (diff.empty())
return false;
bool GIT::getFileRevisionInfo()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;
}
ifs.close();
- tmpf.removeFile();
return !rev_file_cache_.empty();
}
bool GIT::getTreeRevisionInfo()
{
- FileName tmpf = FileName::tempName("lyxvcout");
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;
ifstream ifs(tmpf.toFilesystemEncoding().c_str());
getline(ifs, rev_tree_cache_);
ifs.close();
- tmpf.removeFile();
return !rev_tree_cache_.empty();
}
pointer += ":";
- FileName tmpf = FileName::tempName("lyxvcrev_" + revis + "_");
+ TempFile tempfile("lyxvcrev_" + revis + "_");
+ tempfile.setAutoRemove(false);
+ FileName tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return false;