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()) {
42 deplist[f] = make_pair(one, two);
47 void DepTable::update()
49 for(DepList::iterator itr = deplist.begin();
52 unsigned long const one = (*itr).second.second;
53 unsigned long const two = lyx::sum((*itr).first);
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)) {
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))
119 tmp[(*cit).first] = (*cit).second;
125 void DepTable::write(string const & f) const
127 ofstream ofs(f.c_str());
128 for (DepList::const_iterator cit = deplist.begin();
129 cit != deplist.end(); ++cit) {
130 if (lyxerr.debugging(Debug::DEPEND)) {
131 lyxerr << "Write dep: "
132 << (*cit).first << " "
133 << (*cit).second.first << " "
134 << (*cit).second.second << endl;
136 ofs << (*cit).first << " "
137 << (*cit).second.first << " "
138 << (*cit).second.second << endl;
143 void DepTable::read(string const & f)
145 ifstream ifs(f.c_str());
147 unsigned long one = 0;
148 unsigned long two = 0;
149 while(ifs >> nome >> one >> two) {
150 if (lyxerr.debugging(Debug::DEPEND)) {
151 lyxerr << "Read dep: "
156 deplist[nome] = make_pair(one, two);