Moved the functions getting full paths for files and directories to

obidms.c/.h files
This commit is contained in:
Celine Mercier
2016-04-15 11:11:13 +02:00
parent 71492ad229
commit 527d3555f0
6 changed files with 23 additions and 27 deletions

View File

@ -510,7 +510,7 @@ char* get_full_path_of_avl_dir(OBIDMS_p dms, const char* avl_name)
{
char* avl_dir_name;
avl_dir_name = get_full_path(dms, INDEXER_DIR_NAME);
avl_dir_name = obi_dms_get_full_path(dms, INDEXER_DIR_NAME);
if (avl_dir_name == NULL)
{
obidebug(1, "\nError getting path for the DMS AVL directory");
@ -1286,33 +1286,16 @@ int obi_avl_exists(OBIDMS_p dms, const char* avl_name)
{
struct stat buffer;
char* avl_dir_path;
char* avl_dir_relative_path;
int relative_path_size;
int check_dir;
// Build the AVL tree file path
relative_path_size = strlen(avl_name) + strlen(INDEXER_DIR_NAME) + 2;
avl_dir_relative_path = (char*) malloc(relative_path_size*sizeof(char));
if (avl_dir_relative_path == NULL)
{
obi_set_errno(OBI_MALLOC_ERROR);
obidebug(1, "\nError allocating memory for the path to the AVL directory");
return -1;
}
strcpy(avl_dir_relative_path, INDEXER_DIR_NAME);
strcat(avl_dir_relative_path, "/");
strcat(avl_dir_relative_path, avl_name);
avl_dir_path = get_full_path(dms, avl_dir_relative_path);
avl_dir_path = get_full_path_of_avl_dir(dms, avl_name);
if (avl_dir_path == NULL)
{
obidebug(1, "\nError getting the directory path for an AVL tree");
return -1;
}
check_dir = stat(avl_dir_path, &buffer);
free(avl_dir_path);
free(avl_dir_relative_path);
if (check_dir == 0)
return 1;