Example #1
0
bool
is_up_to_date (url dir) {
  string name_dir= concretize (dir);
  if (cache_valid->contains (name_dir)) return cache_valid [name_dir];
  int l= last_modified (dir, false);
  if (is_cached ("validate_cache.scm", name_dir)) {
    int r= as_int (cache_get ("validate_cache.scm", name_dir) -> label);
    if (l == r) {
      cache_valid (name_dir)= true;
      return true;
    }
    //cout << name_dir << " no longer up to date " << r << " -> " << l << "\n";
  }
  //else cout << name_dir << " not up to date " << l << "\n";
  cache_set ("validate_cache.scm", name_dir, as_string (l));
  cache_valid (name_dir)= false;
  // FIXME: we should explicitly remove all data concerning files in 'dir'
  // from the various caches.  Indeed, at a next run of TeXmacs, the directory
  // will be regarded as up to date, but the other caches may still contain
  // outdated data.  Careful: invalidating the cache lines should not
  // give rise to a performance penaly (e.g. go through all entries of
  // 'cache_data', or reloading unchanged files many times).
  // See also 'declare_out_of_date'.
  return false;
}
bool
disk_storage::handle::expired() const {
  // on disk we consider something expired if it's timestamp is before
  // the planet_timestamp. but since we don't have that, we'll just take
  // the epoch.
  return last_modified() == 0;
}
Example #3
0
void
declare_out_of_date (url dir) {
  //cout << "out of date: " << dir << "\n";
  string name_dir= concretize (dir);
  int l= last_modified (dir, false);
  cache_set ("validate_cache.scm", name_dir, as_string (l));
  cache_valid (name_dir)= false;
  // FIXME: see 'FIXME' in 'is_up_to_date'.
}
Example #4
0
picture
cached_load_picture (url file_name, int w, int h, bool permanent) {
    tree key= tuple (file_name->t, as_string (w), as_string (h));
    if (picture_is_cached (file_name, w, h))
        return picture_cache [key];
    //cout << "Loading " << key << "\n";
    picture pic= load_picture (file_name, w, h);
    if (permanent || picture_count[key] > 0) {
        int pic_modif= last_modified (file_name, false);
        picture_cache (key)= pic;
        picture_stamp (key)= pic_modif;
    }
    return pic;
}
Example #5
0
static bool
picture_is_cached (url file_name, int w, int h) {
    tree key= tuple (file_name->t, as_string (w), as_string (h));
    if (!picture_cache->contains (key)) return false;
    int loaded= last_modified (file_name, false);
    int cached= picture_stamp [key];
    if (cached >= loaded)
        return true;
    else {
        int ow,oh,nw,nh;
        image_size (file_name, ow, oh);
        clear_imgbox_cache (key[0]);
        image_size (file_name, nw, nh);
        // the new size will be displayed correctly only
        // after the typesetter's image box is invalidated.
        // if (nw!=ow || nh!=oh) call("update-current-buffer");
        return false;
    }
}