コード例 #1
0
ファイル: tmfs_convert.cpp プロジェクト: Easycker/itexmacs
void
create_parents (url u) {
  if (!exists (url_parent (u))) {
    if (!is_root (u)) create_parents (url_parent (u));
    mkdir (url_parent (u));
  }
}
コード例 #2
0
ファイル: data_cache.cpp プロジェクト: svn2github/texmacs
bool
is_recursively_up_to_date (url dir) {
  if (!is_up_to_date (dir)) return false;
  bool error_flag;
  array<string> a= read_directory (dir, error_flag);
  for (int i=0; i<N(a); i++)
    if (url (a[i]) != url_here () && url (a[i]) != url_parent ())
      if (is_directory (dir * a[i]))
	if (!is_recursively_up_to_date (dir * a[i]))
	  return false;
  return true;
}
コード例 #3
0
ファイル: url.cpp プロジェクト: svn2github/texmacs
url
delta_sub (url base, url u) {
  if (is_atomic (base))
    return u;
  if (is_concat (base) && is_concat (u) && (base[1] == u[1])) {
    if (is_special_root (base[1]) &&
	is_concat (base[2]) && is_concat (u[2]) &&
	base[2][1] != u[2][1])
      return url_none ();
    return delta_sub (base[2], u[2]);
  }
  if (is_concat (base) && !is_semi_root (base))
    return url_parent () * delta_sub (head (base), u);
  return url_none ();
}
コード例 #4
0
ファイル: url.cpp プロジェクト: svn2github/texmacs
url
operator * (url u1, url u2) {
  //cout << "concat " << u1->t << " * " << u2->t << "\n";
  if (is_root (u2) || (is_concat (u2) && is_root (u2[1]))) {
    if (is_concat (u1) && is_root_web (u1[1])) {
      if (is_root (u2, "default") ||
          (is_concat (u2) && is_root (u2[1], "default")))
        {
          url v= u1[2];
          while (is_concat (v)) v= v[1];
          if (is_root (u2)) return u1[1] * v;
          return u1[1] * v * u2[2];
        }
      if (is_root (u2, "blank") ||
          (is_concat (u2) && is_root (u2[1], "blank")))
        return reroot (u2, u1[1][1]->t->label);
    }
    return u2;
  }
  if (is_here (u1) || (u1->t == "")) return u2;
  if (is_here (u2)) return u1;
  if (is_none (u1)) return url_none ();
  if (is_none (u2)) return url_none ();
  if (u2 == url_parent ()) {
    if (is_root (u1)) return u1;
    if (is_pseudo_atomic (u1) && (!is_parent (u1))) return url_here ();
    if (is_semi_root (u1)) return u1;
  }
  if (is_concat (u2) && (u2[1] == url_parent ())) {
    if (is_root (u1)) return u1 * u2[2];
    if (is_pseudo_atomic (u1) && (!is_parent (u1))) return u2[2];
    if (is_semi_root (u1)) return u1 * u2[2];
  }
  if (is_concat (u1)) return u1[1] * (u1[2] * u2);
  return as_url (tuple ("concat", u1->t, u2->t));
}
コード例 #5
0
ファイル: url.cpp プロジェクト: svn2github/texmacs
string
concretize (url u) {
  // This routine transforms a resolved url into a system file name.
  // In the case of distant files from the web, a local copy is created.
  if (is_rooted (u, "default") ||
      is_rooted (u, "file") ||
      is_rooted (u, "blank"))
        return as_string (reroot (u, "default"));
  if (is_rooted_web (u)) return concretize (get_from_web (u));
  if (is_rooted_tmfs (u)) return concretize (get_from_server (u));
  if (is_ramdisc (u)) return concretize (get_from_ramdisc (u));
  if (is_here (u)) return as_string (url_pwd ());
  if (is_parent (u)) return as_string (url_pwd () * url_parent ());
  if (is_wildcard (u, 1)) return u->t[1]->label;
  std_warning << "Couldn't concretize " << u->t << LF;
  // failed_error << "u= " << u << LF;
  // FAILED ("url has no root");
  return "xxx";
}
コード例 #6
0
tree
evaluate_find_file (tree t) {
  int i, n=N(t);
  array<tree> r (n);
  for (i=0; i<n; i++) {
    r[i]= evaluate (t[i]);
    if (is_compound (r[i]))
      return evaluate_error ("bad find file");
  }
  for (i=0; i<(n-1); i++) {
    url u= resolve (url (r[i]->label, r[n-1]->label));
    if (!is_none (u)) {
      if (is_rooted (u, "default")) u= reroot (u, "file");
      return as_string (u);
    }
  }
  url base_file_name (as_string (std_env["base-file-name"]));
  url u= resolve (base_file_name * url_parent () * r[n-1]->label);
  if (!is_none (u)) {
    if (is_rooted (u, "default")) u= reroot (u, "file");
    return as_string (u);
  }
  return "false";
}
コード例 #7
0
ファイル: tmfs_convert.cpp プロジェクト: Easycker/itexmacs
url
delta_dir (url base, url sub) {
  return url_parent (delta (base * "dummy1", sub * "dummy2"));
}
コード例 #8
0
ファイル: tmfs_convert.cpp プロジェクト: Easycker/itexmacs
collection
tmfs_get_projects (url u) {
  collection c= tmfs_query (seq ("root", "?prj", as_string (u)), "?prj");
  if (N(c) != 0 || is_root (u)) return c;
  return tmfs_get_projects (url_parent (u));
}
コード例 #9
0
ファイル: url.hpp プロジェクト: svn2github/texmacs
inline url url_parent (url u) { return u * url_parent (); }
コード例 #10
0
ファイル: url.cpp プロジェクト: svn2github/texmacs
url
head (url u) {
  return u * url_parent ();
}