1999-09-27 18:44:28 +00:00
|
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
|
* ======================================================
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
|
|
|
|
* LyX, The Document Processor
|
|
|
|
|
* Copyright (C) 1995 Matthias Ettrich
|
|
|
|
|
* Copyright (C) 1995-1998 The LyX Team.
|
|
|
|
|
*
|
|
|
|
|
* This file is Copyright (C) 1996-1998
|
|
|
|
|
* Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
|
* ======================================================
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "DepTable.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#include "support/lyxlib.h"
|
|
|
|
|
#include "support/filetools.h"
|
1999-11-04 01:40:20 +00:00
|
|
|
|
#include <fstream>
|
1999-11-08 13:54:04 +00:00
|
|
|
|
using std::make_pair;
|
|
|
|
|
using std::ofstream;
|
|
|
|
|
using std::ifstream;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
void DepTable::insert(string const & fi,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bool upd,
|
|
|
|
|
unsigned long one,
|
|
|
|
|
unsigned long two)
|
|
|
|
|
{
|
|
|
|
|
// not quite sure if this is the correct place for MakeAbsPath
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string f = MakeAbsPath(fi);
|
1999-11-04 01:40:20 +00:00
|
|
|
|
if (deplist.find(f) == deplist.end()) {
|
|
|
|
|
if (upd) {
|
|
|
|
|
one = two;
|
|
|
|
|
two = lyxsum(f.c_str());
|
|
|
|
|
}
|
|
|
|
|
deplist[f] = make_pair(one, two);
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DepTable::update()
|
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
for(DepList::iterator itr = deplist.begin();
|
|
|
|
|
itr != deplist.end();
|
|
|
|
|
++itr) {
|
|
|
|
|
unsigned long one = (*itr).second.second;
|
|
|
|
|
unsigned long two = lyxsum((*itr).first.c_str());
|
|
|
|
|
(*itr).second = make_pair(one, two);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (lyxerr.debugging()) {
|
1999-11-04 01:40:20 +00:00
|
|
|
|
lyxerr << "update: " << (*itr).first << " "
|
|
|
|
|
<< one << " " << two << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool DepTable::sumchange()
|
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
for (DepList::const_iterator cit = deplist.begin();
|
|
|
|
|
cit != deplist.end();
|
|
|
|
|
++cit) {
|
|
|
|
|
if ((*cit).second.first != (*cit).second.second) return true;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
bool DepTable::haschanged(string const & f)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
// not quite sure if this is the correct place for MakeAbsPath
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string fil = MakeAbsPath(f);
|
1999-11-04 01:40:20 +00:00
|
|
|
|
DepList::const_iterator cit = deplist.find(fil);
|
|
|
|
|
if (cit != deplist.end()) {
|
|
|
|
|
if ((*cit).second.first != (*cit).second.second
|
|
|
|
|
&& (*cit).second.second != 0)
|
|
|
|
|
return true;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
bool DepTable::extchanged(string const & ext)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
for (DepList::const_iterator cit = deplist.begin();
|
|
|
|
|
cit != deplist.end();
|
|
|
|
|
++cit) {
|
|
|
|
|
if (suffixIs((*cit).first, ext.c_str())) {
|
|
|
|
|
if ((*cit).second.first != (*cit).second.second)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
void DepTable::write(string const & f)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
ofstream ofs(f.c_str());
|
|
|
|
|
for (DepList::const_iterator cit = deplist.begin();
|
|
|
|
|
cit != deplist.end();
|
|
|
|
|
++cit) {
|
|
|
|
|
if (lyxerr.debugging()) {
|
|
|
|
|
lyxerr << "Write dep: "
|
|
|
|
|
<< (*cit).first << " "
|
|
|
|
|
<< (*cit).second.first << " "
|
|
|
|
|
<< (*cit).second.second << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
ofs << (*cit).first << " "
|
|
|
|
|
<< (*cit).second.first << " "
|
|
|
|
|
<< (*cit).second.second << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
void DepTable::read(string const &f)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
ifstream ifs(f.c_str());
|
|
|
|
|
string nome;
|
|
|
|
|
unsigned long one = 0;
|
|
|
|
|
unsigned long two = 0;
|
|
|
|
|
while(ifs >> nome >> one >> two) {
|
|
|
|
|
if (lyxerr.debugging()) {
|
|
|
|
|
lyxerr << "read dep: "
|
|
|
|
|
<< nome << " "
|
|
|
|
|
<< one << " "
|
|
|
|
|
<< two << endl;
|
|
|
|
|
}
|
|
|
|
|
deplist[nome] = make_pair(one, two);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|