/**************************************************************************** * Private *at functions * ****************************************************************************/ /** * @file private_at_functions.h * @author Celine Mercier * @date 15 June 2015 * @brief Private replacement functions for *at functions. */ #include #include #include #include #include #include #include #include "private_at_functions.h" /********************************************************************** * * D E F I N I T I O N O F T H E P U B L I C F U N C T I O N S * **********************************************************************/ char* get_full_path(int directory_file_descriptor, const char* path_name) { char* full_path; full_path = (char*) malloc((MAX_PATH_LEN)*sizeof(char)); if (full_path == NULL) return NULL; if (fcntl(directory_file_descriptor, F_GETPATH, full_path) < 0) return NULL; // check errors TODO strlcat(full_path, "/", MAX_PATH_LEN); strlcat(full_path, path_name, MAX_PATH_LEN); return full_path; } DIR* private_opendirat(int directory_file_descriptor, const char* path_name) { char* full_path; DIR* directory; full_path = get_full_path(directory_file_descriptor, path_name); if (full_path == NULL) return NULL; directory = opendir(full_path); free(full_path); return directory; } //int private_openat(int directory_file_descriptor, const char* path_name, int flags) //{ // char* full_path; // int file_descriptor; // // full_path = get_full_path(directory_file_descriptor, path_name); // if (full_path == NULL) // return -1; // // file_descriptor = open(full_path, flags); // // free(full_path); // // return file_descriptor; //} // // //int private_mkdirat(int directory_file_descriptor, const char* path_name, mode_t mode) //{ // char* full_path; // // full_path = get_full_path(directory_file_descriptor, path_name); // if (full_path == NULL) // return -1; // // if (mkdir(full_path, mode) < 0) // { // free(full_path); // return -1; // } // // free(full_path); // // return 0; //}