/* * Sets a scaffold name. * * Returns 0 on success * -1 on failure */ int scaffold_set_name(GapIO *io, scaffold_t **f, char *name) { scaffold_t *n; GapIO *iob = gio_base(io); if (!(n = cache_rw(io, *f))) return -1; /* Delete old name */ if (n->name) { tg_rec r = iob->iface->scaffold.index_del(iob->dbh, n->name, n->rec); if (r != -1 && r != io->db->scaffold_name_index) { io->db = cache_rw(io, io->db); io->db->scaffold_name_index = r; } } if (NULL == (n = cache_item_resize(n, sizeof(*n) + strlen(name)+1))) return -1; *f = n; /* Add new name */ n->name = (char *)(&n->data); strcpy(n->name, name); if (*name) { tg_rec r = iob->iface->scaffold.index_add(iob->dbh, name, n->rec); if (r != -1 && r != io->db->scaffold_name_index) { io->db = cache_rw(io, io->db); io->db->scaffold_name_index = r; } } return 0; }
int io_timestamp_incr(GapIO *io) { io = gio_base(io); io->db = cache_rw(io, io->db); return ++io->db->timestamp; }