Error handling: obidebug() with message for all errors, and removed
commands closing directories when an error occurred (creating more errors).
This commit is contained in:
@ -19,6 +19,11 @@
|
||||
#include <dirent.h>
|
||||
|
||||
#include "private_at_functions.h"
|
||||
#include "obidebug.h"
|
||||
#include "obierrno.h"
|
||||
|
||||
|
||||
#define DEBUG_LEVEL 0
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
@ -34,12 +39,18 @@ char* get_full_path(int directory_file_descriptor, const char* path_name)
|
||||
|
||||
full_path = (char*) malloc((MAX_PATH_LEN)*sizeof(char));
|
||||
if (full_path == NULL)
|
||||
{
|
||||
obidebug(1, "\nError allocating memory for the char* path to a file or directory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fcntl(directory_file_descriptor, F_GETPATH, full_path) < 0)
|
||||
{
|
||||
obidebug(1, "\nError getting the path to a file or directory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// check errors TODO
|
||||
// TODO check errors
|
||||
strlcat(full_path, "/", MAX_PATH_LEN);
|
||||
strlcat(full_path, path_name, MAX_PATH_LEN);
|
||||
|
||||
@ -57,6 +68,8 @@ DIR* private_opendirat(int directory_file_descriptor, const char* path_name)
|
||||
return NULL;
|
||||
|
||||
directory = opendir(full_path);
|
||||
if (directory == NULL)
|
||||
obidebug(1, "\nError opening a directory");
|
||||
|
||||
free(full_path);
|
||||
|
||||
|
Reference in New Issue
Block a user