1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright (C) 1995 Matthias Ettrich
6 * Copyright (C) 1995-1998 The LyX Team.
8 * This file is Copyright (C) 1996-1998
11 * ======================================================
17 #pragma implementation
21 #include "support/lyxlib.h"
22 #include "support/filetools.h"
28 void DepTable::insert(string const & fi,
33 // not quite sure if this is the correct place for MakeAbsPath
34 string f = MakeAbsPath(fi);
35 if (deplist.find(f) == deplist.end()) {
38 two = lyx::sum(f.c_str());
40 deplist[f] = make_pair(one, two);
45 void DepTable::update()
47 for(DepList::iterator itr = deplist.begin();
50 unsigned long one = (*itr).second.second;
51 unsigned long two = lyx::sum((*itr).first.c_str());
52 (*itr).second = make_pair(one, two);
53 if (lyxerr.debugging(Debug::DEPEND)) {
54 lyxerr << "Update dep: " << (*itr).first << " "
64 bool DepTable::sumchange() const
66 for (DepList::const_iterator cit = deplist.begin();
69 if ((*cit).second.first != (*cit).second.second) return true;
75 bool DepTable::haschanged(string const & f) const
77 // not quite sure if this is the correct place for MakeAbsPath
78 string fil = MakeAbsPath(f);
79 DepList::const_iterator cit = deplist.find(fil);
80 if (cit != deplist.end()) {
81 if ((*cit).second.first != (*cit).second.second
82 && (*cit).second.second != 0)
89 bool DepTable::extchanged(string const & ext) const
91 for (DepList::const_iterator cit = deplist.begin();
94 if (suffixIs((*cit).first, ext.c_str())) {
95 if ((*cit).second.first != (*cit).second.second)
103 bool DepTable::exist(string const & fil) const
105 DepList::const_iterator cit = deplist.find(fil);
106 if (cit != deplist.end()) return true;
111 void DepTable::remove_files_with_extension(string const & suf)
114 for (DepList::const_iterator cit = deplist.begin();
115 cit != deplist.end(); ++cit) {
116 if (!suffixIs((*cit).first, suf.c_str()))
117 tmp[(*cit).first] = (*cit).second;
124 void DepTable::write(string const & f) const
126 ofstream ofs(f.c_str());
127 for (DepList::const_iterator cit = deplist.begin();
128 cit != deplist.end();
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);