1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-2000 The LyX Team.
8 * This file is Copyright 1996-2000
11 * ======================================================
17 #pragma implementation
21 #include "support/lyxlib.h"
22 #include "support/filetools.h"
30 void DepTable::insert(string const & fi,
35 // not quite sure if this is the correct place for MakeAbsPath
36 string f = MakeAbsPath(fi);
37 if (deplist.find(f) == deplist.end()) {
40 two = lyx::sum(f.c_str());
42 deplist[f] = make_pair(one, two);
47 void DepTable::update()
49 for(DepList::iterator itr = deplist.begin();
52 unsigned long one = (*itr).second.second;
53 unsigned long two = lyx::sum((*itr).first.c_str());
54 (*itr).second = make_pair(one, two);
55 if (lyxerr.debugging(Debug::DEPEND)) {
56 lyxerr << "Update dep: " << (*itr).first << " "
66 bool DepTable::sumchange() const
68 for (DepList::const_iterator cit = deplist.begin();
71 if ((*cit).second.first != (*cit).second.second) return true;
77 bool DepTable::haschanged(string const & f) const
79 // not quite sure if this is the correct place for MakeAbsPath
80 string fil = MakeAbsPath(f);
81 DepList::const_iterator cit = deplist.find(fil);
82 if (cit != deplist.end()) {
83 if ((*cit).second.first != (*cit).second.second
84 && (*cit).second.second != 0)
91 bool DepTable::extchanged(string const & ext) const
93 for (DepList::const_iterator cit = deplist.begin();
96 if (suffixIs((*cit).first, ext.c_str())) {
97 if ((*cit).second.first != (*cit).second.second)
105 bool DepTable::exist(string const & fil) const
107 DepList::const_iterator cit = deplist.find(fil);
108 if (cit != deplist.end()) return true;
113 void DepTable::remove_files_with_extension(string const & suf)
116 for (DepList::const_iterator cit = deplist.begin();
117 cit != deplist.end(); ++cit) {
118 if (!suffixIs((*cit).first, suf.c_str()))
119 tmp[(*cit).first] = (*cit).second;
126 void DepTable::write(string const & f) const
128 ofstream ofs(f.c_str());
129 for (DepList::const_iterator cit = deplist.begin();
130 cit != deplist.end();
132 if (lyxerr.debugging(Debug::DEPEND)) {
133 lyxerr << "Write dep: "
134 << (*cit).first << " "
135 << (*cit).second.first << " "
136 << (*cit).second.second << endl;
138 ofs << (*cit).first << " "
139 << (*cit).second.first << " "
140 << (*cit).second.second << endl;
145 void DepTable::read(string const & f)
147 ifstream ifs(f.c_str());
149 unsigned long one = 0;
150 unsigned long two = 0;
151 while(ifs >> nome >> one >> two) {
152 if (lyxerr.debugging(Debug::DEPEND)) {
153 lyxerr << "Read dep: "
158 deplist[nome] = make_pair(one, two);