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 = lyxsum(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 = lyxsum((*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()
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)
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)
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 void DepTable::write(string const & f)
103 ofstream ofs(f.c_str());
104 for (DepList::const_iterator cit = deplist.begin();
105 cit != deplist.end();
107 if (lyxerr.debugging()) {
108 lyxerr << "Write dep: "
109 << (*cit).first << " "
110 << (*cit).second.first << " "
111 << (*cit).second.second << endl;
113 ofs << (*cit).first << " "
114 << (*cit).second.first << " "
115 << (*cit).second.second << endl;
119 void DepTable::read(string const &f)
121 ifstream ifs(f.c_str());
123 unsigned long one = 0;
124 unsigned long two = 0;
125 while(ifs >> nome >> one >> two) {
126 if (lyxerr.debugging()) {
127 lyxerr << "read dep: "
132 deplist[nome] = make_pair(one, two);