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"
25 void DepTable::insert(string const & fi,
30 // not quite sure if this is the correct place for MakeAbsPath
31 string f = MakeAbsPath(fi);
32 if (deplist.find(f) == deplist.end()) {
35 two = lyxsum(f.c_str());
37 deplist[f] = make_pair(one, two);
42 void DepTable::update()
44 for(DepList::iterator itr = deplist.begin();
47 unsigned long one = (*itr).second.second;
48 unsigned long two = lyxsum((*itr).first.c_str());
49 (*itr).second = make_pair(one, two);
50 if (lyxerr.debugging()) {
51 lyxerr << "update: " << (*itr).first << " "
52 << one << " " << two << endl;
58 bool DepTable::sumchange()
60 for (DepList::const_iterator cit = deplist.begin();
63 if ((*cit).second.first != (*cit).second.second) return true;
69 bool DepTable::haschanged(string const & f)
71 // not quite sure if this is the correct place for MakeAbsPath
72 string fil = MakeAbsPath(f);
73 DepList::const_iterator cit = deplist.find(fil);
74 if (cit != deplist.end()) {
75 if ((*cit).second.first != (*cit).second.second
76 && (*cit).second.second != 0)
83 bool DepTable::extchanged(string const & ext)
85 for (DepList::const_iterator cit = deplist.begin();
88 if (suffixIs((*cit).first, ext.c_str())) {
89 if ((*cit).second.first != (*cit).second.second)
98 void DepTable::write(string const & f)
100 ofstream ofs(f.c_str());
101 for (DepList::const_iterator cit = deplist.begin();
102 cit != deplist.end();
104 if (lyxerr.debugging()) {
105 lyxerr << "Write dep: "
106 << (*cit).first << " "
107 << (*cit).second.first << " "
108 << (*cit).second.second << endl;
110 ofs << (*cit).first << " "
111 << (*cit).second.first << " "
112 << (*cit).second.second << endl;
116 void DepTable::read(string const &f)
118 ifstream ifs(f.c_str());
120 unsigned long one = 0;
121 unsigned long two = 0;
122 while(ifs >> nome >> one >> two) {
123 if (lyxerr.debugging()) {
124 lyxerr << "read dep: "
129 deplist[nome] = make_pair(one, two);