1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-2001 The LyX Team.
8 * This file is Copyright 1996-2001
11 * ======================================================
17 #pragma implementation
21 #include "support/lyxlib.h"
22 #include "support/filetools.h"
31 void DepTable::insert(string const & fi,
36 // not quite sure if this is the correct place for MakeAbsPath
37 string f = MakeAbsPath(fi);
38 if (deplist.find(f) == deplist.end()) {
43 deplist[f] = make_pair(one, two);
48 void DepTable::update()
50 for (DepList::iterator itr = deplist.begin();
53 unsigned long const one = itr->second.second;
54 unsigned long const two = lyx::sum(itr->first);
55 itr->second = make_pair(one, two);
56 if (lyxerr.debugging(Debug::DEPEND)) {
57 lyxerr << "Update dep: " << itr->first << " "
67 bool DepTable::sumchange() const
69 for (DepList::const_iterator cit = deplist.begin();
72 if ((*cit).second.first != cit->second.second) return true;
78 bool DepTable::haschanged(string const & f) const
80 // not quite sure if this is the correct place for MakeAbsPath
81 string fil = MakeAbsPath(f);
82 DepList::const_iterator cit = deplist.find(fil);
83 if (cit != deplist.end()) {
84 if (cit->second.first != cit->second.second
85 && cit->second.second != 0)
92 bool DepTable::extchanged(string const & ext) const
94 for (DepList::const_iterator cit = deplist.begin();
97 if (suffixIs(cit->first, ext)) {
98 if (cit->second.first != cit->second.second)
106 bool DepTable::exist(string const & fil) const
108 DepList::const_iterator cit = deplist.find(fil);
109 if (cit != deplist.end()) return true;
114 void DepTable::remove_files_with_extension(string const & suf)
117 // we want const_iterator (Lgb)
118 for (DepList::iterator cit = deplist.begin();
119 cit != deplist.end(); ++cit) {
120 if (!suffixIs(cit->first, suf))
121 tmp[cit->first] = cit->second;
127 void DepTable::write(string const & f) const
129 ofstream ofs(f.c_str());
130 for (DepList::const_iterator cit = deplist.begin();
131 cit != deplist.end(); ++cit) {
132 if (lyxerr.debugging(Debug::DEPEND)) {
133 lyxerr << "Write dep: "
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);