Beispiel #1
0
/* _unix_desk_sync_tofu(): sync out file install.
*/
static void
_unix_desk_sync_tofu(u2_udir* dir_u,
                     u2_noun  pre,
                     u2_noun  ext,
                     u2_noun  mis)
{
  c3_c*     pox_c = _unix_file_form(dir_u, u2k(pre), u2_no, u2k(ext));
  c3_c*     pux_c = _unix_file_form(dir_u, u2k(pre), u2_yes, u2k(ext));
  u2_ufil** fil_u;

  // uL(fprintf(uH, "tofu pox_c %s op %s\n", pox_c, u2_cr_string(u2h(mis))));

  fil_u = &(dir_u->fil_u); 
  while ( 1 ) {                               //  XX crude!
    if ( !*fil_u || 
         !strcmp((*fil_u)->pax_c, pox_c) ||
         !strcmp((*fil_u)->pax_c, pux_c) )
    {
      break;
    }
    else fil_u = &((*fil_u)->nex_u);
  }
 
  if ( *fil_u && (c3__del == u2h(mis)) ) {
    u2_ufil* ded_u = *fil_u;

    *fil_u = ded_u->nex_u;
    _unix_unlink(ded_u->pax_c);
    _unix_file_free(ded_u);

    free(ded_u);
    free(pox_c);
    free(pux_c);
  }
  else {
    u2_noun god, oat;
    c3_c*   pax_c;

    if ( *fil_u ) {
      u2_noun old = _unix_file_load(*fil_u);
      c3_assert(c3__mut == u2h(mis));

      god = _unix_desk_sync_udon(u2k(u2t(mis)), old);
      _unix_unlink((*fil_u)->pax_c);
      free((*fil_u)->pax_c);
    } 
    else {
      c3_assert(c3__ins == u2h(mis));
      god = u2k(u2t(mis));
    }

    if ( u2_yes == u2du(god) ) {
      oat = u2_cke_jam(god);
      pax_c = pux_c; free(pox_c);
    } else {
      oat = god;
      pax_c = pox_c; free(pux_c);
    }

    if ( *fil_u ) {
      (*fil_u)->dot_c = (pax_c + ((*fil_u)->dot_c - (*fil_u)->pax_c));
      (*fil_u)->pax_c = pax_c;

      mpz_clear((*fil_u)->mod_mp);
      u2_cr_mp((*fil_u)->mod_mp, u2A->now);
    } 
    else {
      mpz_t mod_mp;

      u2_cr_mp(mod_mp, u2A->now);
      *fil_u = malloc(sizeof(u2_ufil));

      _unix_file_watch(*fil_u, dir_u, pax_c, mod_mp);
      mpz_clear(mod_mp);
    }

    _unix_save((*fil_u)->pax_c, oat);
  }
  u2z(pre); u2z(ext); u2z(mis);
}
Beispiel #2
0
/* _unix_desk_sync_tofu(): sync out file install.
*/
static void
_unix_desk_sync_tofu(u2_udir* dir_u,
                     u2_noun  pre,
                     u2_noun  ext,
                     u2_noun  mis)
{
  c3_c*     pox_c = _unix_file_form(dir_u, u2k(pre), u2_no, u2k(ext));
  c3_c*     pux_c = _unix_file_form(dir_u, u2k(pre), u2_yes, u2k(ext));
  u2_ufil** fil_u;

  // uL(fprintf(uH, "tofu pox_c %s op %s\n", pox_c, u2_cr_string(u2h(mis))));

#ifdef SYNCLOG
  c3_w slot = u2_Host.unx_u.lot_w++ % 1024;
  free(u2_Host.unx_u.sylo[slot].pax_c);
  u2_Host.unx_u.sylo[slot].pax_c = 0;
#endif

  fil_u = &(dir_u->fil_u);
  while ( 1 ) {                               //  XX crude!
    if ( !*fil_u ||
         !strcmp((*fil_u)->pax_c, pox_c) ||
         !strcmp((*fil_u)->pax_c, pux_c) )
    {
      break;
    }
    else fil_u = &((*fil_u)->nex_u);
  }

  if ( *fil_u && (c3__del == u2h(mis)) ) {
    u2_ufil* ded_u = *fil_u;

#ifdef SYNCLOG
    u2_Host.unx_u.sylo[slot].unx   = u2_no;
    u2_Host.unx_u.sylo[slot].wer_m = c3_s4('t','o','f','u');
    u2_Host.unx_u.sylo[slot].wot_m = c3__del;
    u2_Host.unx_u.sylo[slot].pax_c = strdup(ded_u->pax_c);
#endif

    *fil_u = ded_u->nex_u;
    _unix_unlink(ded_u->pax_c);
    _unix_file_free(ded_u);

    free(pox_c);
    free(pux_c);
  }
  else {
    u2_noun god, oat;
    c3_c*   pax_c;

    if ( *fil_u ) {
      u2_noun old = _unix_file_load(*fil_u);
      c3_assert(c3__mut == u2h(mis));

      god = _unix_desk_sync_udon(u2k(u2t(mis)), old);
      _unix_unlink((*fil_u)->pax_c);
      free((*fil_u)->pax_c);
    }
    else {
      c3_assert(c3__ins == u2h(mis));
      god = u2k(u2t(mis));
    }

    if ( u2_yes == u2du(god) ) {
      oat = u2_cke_jam(god);
      pax_c = pux_c; free(pox_c);
    } else {
      oat = god;
      pax_c = pox_c; free(pux_c);
    }

#ifdef SYNCLOG
    u2_Host.unx_u.sylo[slot].unx   = u2_no;
    u2_Host.unx_u.sylo[slot].wer_m = c3_s4('t','o','f','u');
    u2_Host.unx_u.sylo[slot].wot_m = u2h(mis);
    u2_Host.unx_u.sylo[slot].pax_c = strdup(pax_c);
#endif

    _unix_save(pax_c, oat);

    if ( *fil_u ) {
      (*fil_u)->dot_c = (pax_c + ((*fil_u)->dot_c - (*fil_u)->pax_c));
      (*fil_u)->pax_c = pax_c;

      mpz_clear((*fil_u)->mod_mp);
      u2_cr_mp((*fil_u)->mod_mp, u2A->now);
    }
    else {
      mpz_t mod_mp;

      u2_cr_mp(mod_mp, u2A->now);
      *fil_u = c3_malloc(sizeof(u2_ufil));

      _unix_file_watch(*fil_u, dir_u, pax_c, mod_mp);
      mpz_clear(mod_mp);
    }
  }
  u2z(pre); u2z(ext); u2z(mis);
}