MCPcopy Create free account
hub / github.com/crawl/crawl / _needs_update

Method _needs_update

crawl-ref/source/database.cc:243–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243bool TextDB::_needs_update() const
244{
245 string ts;
246 bool no_files = true;
247
248 for (const string &file : _input_files)
249 {
250 string full_input_path = _directory + file;
251 full_input_path = datafile_path(full_input_path, !_parent);
252 // packagers who mess with mtime beware: you shouldn't put the db in
253 // a shared folder, as a fixed mtime will break this check.
254 time_t mtime = file_modtime(full_input_path);
255 const bool exists = file_exists(full_input_path);
256 if (exists || !_parent)
257 {
258 if (exists)
259 no_files = false;
260 char buf[20];
261 snprintf(buf, sizeof(buf), ":%" PRId64, (int64_t)mtime);
262 ts += buf;
263 }
264 }
265
266 if (no_files)
267 {
268 // No point in empty databases, although for simplicity keep ones
269 // for disappeared translations for now.
270 ASSERTM(_parent,
271 "No readable database files in `%s` (internal error).",
272 _directory.c_str());
273 TextDB *en = _parent;
274 delete en->translation; // ie, ourself
275 en->translation = 0;
276 return false;
277 }
278
279 return ts != timestamp;
280}
281
282void TextDB::_regenerate_db()
283{

Callers

nothing calls this directly

Calls 3

datafile_pathFunction · 0.85
file_modtimeFunction · 0.85
file_existsFunction · 0.85

Tested by

no test coverage detected