It is now impossible to create a view with a name identical to one of an
existing written view
This commit is contained in:
@ -224,6 +224,8 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
|
||||
}
|
||||
|
||||
view = obi_new_view(dms, view_name, view_to_clone, line_selection, comments);
|
||||
if (view== NULL)
|
||||
return NULL;
|
||||
|
||||
strcpy(view->view_type, VIEW_TYPE_NUC_SEQS);
|
||||
|
||||
@ -258,6 +260,24 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
||||
Obiview_p view;
|
||||
int i;
|
||||
index_t line_nb;
|
||||
Obiviews_infos_all_p views_infos;
|
||||
|
||||
// Check uniqueness of name TODO but problem if view not written yet has the same name
|
||||
views_infos = obi_read_views(dms);
|
||||
if (views_infos != NULL)
|
||||
{
|
||||
for (i=0; i<((views_infos->header)->view_count); i++)
|
||||
{
|
||||
if (strcmp(((views_infos->view_infos)+i)->name, view_name) == 0) // TODO discuss what to do
|
||||
{
|
||||
obi_set_errno(OBIVIEW_ERROR);
|
||||
obidebug(1, "\nView name already exists for a previous view");
|
||||
obi_unmap_read_views(views_infos);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
obi_unmap_read_views(views_infos);
|
||||
}
|
||||
|
||||
view = (Obiview_p) malloc(sizeof(Obiview_t));
|
||||
if (view == NULL)
|
||||
@ -646,6 +666,28 @@ Obiviews_infos_all_p obi_read_views(OBIDMS_p dms)
|
||||
}
|
||||
|
||||
|
||||
int obi_unmap_read_views(Obiviews_infos_all_p views)
|
||||
{
|
||||
if (munmap(views->view_infos, (views->header)->views_size) < 0)
|
||||
{
|
||||
obi_set_errno(OBIVIEW_ERROR);
|
||||
obidebug(1, "\nError unmapping the views of an obiview file");
|
||||
free(views);
|
||||
return -1;
|
||||
}
|
||||
if (munmap(views->header, (views->header)->header_size) < 0)
|
||||
{
|
||||
obi_set_errno(OBIVIEW_ERROR);
|
||||
obidebug(1, "\nError unmapping the header of an obiview file");
|
||||
free(views);
|
||||
return -1;
|
||||
|
||||
}
|
||||
free(views);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int obi_view_add_column(Obiview_p view,
|
||||
const char* column_name,
|
||||
obiversion_t version_number,
|
||||
|
@ -153,6 +153,8 @@ Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name);
|
||||
|
||||
Obiviews_infos_all_p obi_read_views(OBIDMS_p dms);
|
||||
|
||||
int obi_unmap_read_views(Obiviews_infos_all_p views);
|
||||
|
||||
int obi_view_add_column(Obiview_p view,
|
||||
const char* column_name,
|
||||
obiversion_t version_number,
|
||||
|
Reference in New Issue
Block a user