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()) {
54 lyxerr << "update: " << (*itr).first << " "
55 << one << " " << two << endl;
61 bool DepTable::sumchange() const
63 for (DepList::const_iterator cit = deplist.begin();
66 if ((*cit).second.first != (*cit).second.second) return true;
72 bool DepTable::haschanged(string const & f) const
74 // not quite sure if this is the correct place for MakeAbsPath
75 string fil = MakeAbsPath(f);
76 DepList::const_iterator cit = deplist.find(fil);
77 if (cit != deplist.end()) {
78 if ((*cit).second.first != (*cit).second.second
79 && (*cit).second.second != 0)
86 bool DepTable::extchanged(string const & ext) const
88 for (DepList::const_iterator cit = deplist.begin();
91 if (suffixIs((*cit).first, ext.c_str())) {
92 if ((*cit).second.first != (*cit).second.second)
101 bool DepTable::exist(string const & fil) const
103 DepList::const_iterator cit = deplist.find(fil);
104 if (cit != deplist.end()) return true;
109 void DepTable::remove_files_with_extension(string const & suf)
112 for (DepList::const_iterator cit = deplist.begin();
113 cit != deplist.end(); ++cit) {
114 if (!suffixIs((*cit).first, suf.c_str()))
115 tmp[(*cit).first] = (*cit).second;
122 void DepTable::write(string const & f) const
124 ofstream ofs(f.c_str());
125 for (DepList::const_iterator cit = deplist.begin();
126 cit != deplist.end();
128 if (lyxerr.debugging()) {
129 lyxerr << "Write dep: "
130 << (*cit).first << " "
131 << (*cit).second.first << " "
132 << (*cit).second.second << endl;
134 ofs << (*cit).first << " "
135 << (*cit).second.first << " "
136 << (*cit).second.second << endl;
141 void DepTable::read(string const & f)
143 ifstream ifs(f.c_str());
145 unsigned long one = 0;
146 unsigned long two = 0;
147 while(ifs >> nome >> one >> two) {
148 if (lyxerr.debugging()) {
149 lyxerr << "read dep: "
154 deplist[nome] = make_pair(one, two);