Commit 8724445f by Celine Mercier

Added error checking when closing files

parent de189fd7
......@@ -191,7 +191,13 @@ int create_dms_infos_file(int dms_file_descriptor, const char* dms_name)
}
// Close file
close(infos_file_descriptor);
if (close(infos_file_descriptor) < 0)
{
obi_set_errno(OBIDMS_UNKNOWN_ERROR);
obidebug(1, "\nError closing a DMS information file");
return -1;
}
return 0;
}
......@@ -427,7 +433,12 @@ OBIDMS_p obi_open_dms(const char* dms_path)
return NULL;
}
close(infos_file_descriptor);
if (close(infos_file_descriptor) < 0)
{
obi_set_errno(OBIDMS_UNKNOWN_ERROR);
obidebug(1, "\nError closing a DMS information file");
return NULL;
}
dms->little_endian = little_endian_dms;
......@@ -518,13 +529,6 @@ int obi_close_dms(OBIDMS_p dms)
obi_close_column(*((dms->opened_columns)->columns));
// Close dms, and view and indexer directories
if (closedir(dms->directory) < 0)
{
obi_set_errno(OBIDMS_MEMORY_ERROR);
obidebug(1, "\nError closing an OBIDMS directory");
free(dms);
return -1;
}
if (closedir(dms->indexer_directory) < 0)
{
obi_set_errno(OBI_INDEXER_ERROR);
......@@ -539,6 +543,13 @@ int obi_close_dms(OBIDMS_p dms)
free(dms);
return -1;
}
if (closedir(dms->directory) < 0)
{
obi_set_errno(OBIDMS_MEMORY_ERROR);
obidebug(1, "\nError closing an OBIDMS directory");
free(dms);
return -1;
}
free(dms);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment