Files
obitools3/src/private_at_functions.h

88 lines
2.8 KiB
C

/**
* @file private_openat.h
* @author Celine Mercier
* @date 15 June 2015
* @brief Header file for the replacement *at function.
*/
#ifndef PRIVATE_OPENAT_H_
#define PRIVATE_OPENAT_H_
#include <sys/stat.h>
#define MAX_PATH_LEN 4096
/**
* Internal function getting the full path of a file or a directory from its
* path relative to a directory file descriptor.
*
*
* @warning The returned pointer has to be freed by the caller.
*
* @param directory_file_descriptor the file descriptor for the directory to which
* path_name is relative
* @param path_name the path name for the file or directory, relative to directory_file_descriptor
*
* @return a pointer to the full path
* @retvalue <full_path> if everything is ok
* @retvalue NULL if an error occurs
*
* ###Error values
* - OBIDMS_MEMORY_ERROR : something wrong occurred during memory allocation.
* - OBIDMS_LONG_NAME_ERROR : the database name exceeds the limit.
*
* @since June 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
char* get_full_path(int directory_file_descriptor, const char* path_name);
/**
* @brief Replacement function for openat() : open a file relative to a directory file descriptor.
*
* @param directory_file_descriptor the file descriptor for the directory in which the file should be opened
* @param path_name the path name for the file, relative to directory_file_descriptor
* @param flags the access modes
*
* @return the file descriptor of the opened file
*
* @since June 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int private_openat(int directory_file_descriptor, const char* path_name, int flags);
/**
* @brief Replacement function for mkdirat() : create a directory relative to a directory file descriptor.
*
* @param directory_file_descriptor the file descriptor for the directory in which the directory should be created
* @param path_name the path name for the new directory, relative to directory_file_descriptor
* @param mode the access mode
*
* @return the file descriptor of the created directory
*
* @since June 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int private_mkdirat(int directory_file_descriptor, const char* path_name, mode_t mode);
/**
* @brief Replacement function for opendirat() : open a directory relative to a directory file descriptor.
*
* @param directory_file_descriptor the file descriptor for the directory in which the directory should be opened
* @param path_name the path name for the directory to be opened, relative to directory_file_descriptor
*
* @return the file descriptor of the opened directory
*
* @since June 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
DIR* private_opendirat(int directory_file_descriptor, const char* path_name);
#endif /* PRIVATEOPENAT_H_ */