Files
obitools3/src/utils.h
2016-04-08 15:38:57 +02:00

71 lines
2.0 KiB
C

/****************************************************************************
* Header file for utility functions *
****************************************************************************/
/**
* @file utils.h
* @author Celine Mercier (celine.mercier@metabarcoding.org)
* @date 29 March 2016
* @brief Header file for utility functions.
*/
#ifndef UTILS_H_
#define UTILS_H_
#include <stdio.h>
#include <sys/stat.h>
#include "obidms.h"
#define ONE_IF_ZERO(x) (((x)==0)?1:(x)) /**< If x is equal to 0, x takes the value 1.
*/
#define MAX_PATH_LEN 4096 /**< Maximum length for the character string defining a
* file or directory path.
*/
/**
* @brief 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.
*
* @returns A pointer to the full path.
* @retval NULL if an error occurred.
*
* @since June 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
char* get_full_path(OBIDMS_p dms, const char* path_name);
/**
* @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.
*
* @returns The file descriptor of the opened directory.
* @retval NULL if an error occurred.
*
* @since June 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
DIR* opendir_in_dms(OBIDMS_p dms, const char* path_name);
/*
* TODO
*/
int count_dir(char *dir);
#endif /* UTILS_H_ */