C: optimized dir opening
This commit is contained in:
13
src/obiavl.c
13
src/obiavl.c
@ -1964,9 +1964,6 @@ OBIDMS_avl_group_p obi_create_avl_group(OBIDMS_p dms, const char* avl_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Store pointer on directory
|
||||
avl_group->directory = opendir(avl_dir_name);
|
||||
|
||||
// Add in the list of open indexers
|
||||
obi_dms_list_indexer(dms, avl_group);
|
||||
|
||||
@ -2031,9 +2028,6 @@ OBIDMS_avl_group_p obi_open_avl_group(OBIDMS_p dms, const char* avl_name)
|
||||
|
||||
avl_group->dms = dms;
|
||||
|
||||
// Store pointer on directory
|
||||
avl_group->directory = opendir(avl_dir_name);
|
||||
|
||||
// Add in the list of open indexers
|
||||
obi_dms_list_indexer(dms, avl_group);
|
||||
|
||||
@ -2195,13 +2189,6 @@ int obi_close_avl_group(OBIDMS_avl_group_p avl_group)
|
||||
ret_val = -1;
|
||||
}
|
||||
|
||||
if (closedir(avl_group->directory) < 0)
|
||||
{
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
obidebug(1, "\nError closing an AVL group directory");
|
||||
ret_val = -1;
|
||||
}
|
||||
|
||||
free(avl_group);
|
||||
}
|
||||
|
||||
|
@ -161,8 +161,6 @@ typedef struct OBIDMS_avl_group {
|
||||
*/
|
||||
bool writable; /**< Indicates whether the AVL group is read-only or not.
|
||||
*/
|
||||
DIR* directory; /**< A directory entry usable to refer and scan the AVL group directory.
|
||||
*/
|
||||
size_t counter; /**< Indicates by how many threads/programs (TODO) the AVL group is used.
|
||||
*/
|
||||
} OBIDMS_avl_group_t, *OBIDMS_avl_group_p;
|
||||
|
@ -764,6 +764,13 @@ OBIDMS_p obi_create_dms(const char* dms_path)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (closedir(dms_dir) < 0)
|
||||
{
|
||||
obi_set_errno(OBIDMS_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError closing a directory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dms;
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,12 @@ int count_dir(char* dir_path)
|
||||
count++;
|
||||
}
|
||||
|
||||
closedir(fd);
|
||||
if (closedir(fd) < 0)
|
||||
{
|
||||
obi_set_errno(OBI_UTILS_ERROR);
|
||||
obidebug(1, "\nError closing a directory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
Reference in New Issue
Block a user