2015-06-23 18:35:34 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* OBIDMS column directories header file *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/**
|
2015-06-26 17:53:03 +02:00
|
|
|
* @file obidmscolumndir.h
|
2015-06-23 18:35:34 +02:00
|
|
|
* @author Celine Mercier
|
|
|
|
* @date 18 June 2015
|
2015-09-30 12:03:46 +02:00
|
|
|
* @brief Header file for the OBIDMS column directories structures and functions.
|
2015-06-23 18:35:34 +02:00
|
|
|
*/
|
|
|
|
|
2015-09-30 12:03:46 +02:00
|
|
|
|
2015-06-23 18:35:34 +02:00
|
|
|
#ifndef OBIDMSCOLUMNGROUP_H_
|
|
|
|
#define OBIDMSCOLUMNGROUP_H_
|
|
|
|
|
2015-09-30 12:03:46 +02:00
|
|
|
|
2015-06-23 18:35:34 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
|
|
|
|
#include "obidms.h"
|
|
|
|
|
|
|
|
|
2015-11-10 10:56:45 +01:00
|
|
|
#define OBIDMS_COLUMN_MAX_NAME (1024) /**< The maximum length of an OBIDMS column name.
|
2015-09-30 12:03:46 +02:00
|
|
|
*/
|
|
|
|
|
2015-06-23 18:35:34 +02:00
|
|
|
|
2015-09-30 12:03:46 +02:00
|
|
|
/**
|
|
|
|
* @brief A structure describing an OBIDMS column directory instance.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
|
|
|
* A pointer to this structure is returned on creation
|
2015-06-26 17:53:03 +02:00
|
|
|
* and opening of an OBIDMS column directory.
|
2015-06-23 18:35:34 +02:00
|
|
|
*/
|
2015-06-26 17:53:03 +02:00
|
|
|
typedef struct OBIDMS_column_directory {
|
2015-09-30 12:03:46 +02:00
|
|
|
OBIDMS_p dms; /**< A pointer to a DMS instance.
|
2015-11-09 15:06:02 +01:00
|
|
|
*/
|
2015-09-30 12:03:46 +02:00
|
|
|
char column_name[OBIDMS_COLUMN_MAX_NAME+1]; /**< The name of the column
|
2015-11-09 15:06:02 +01:00
|
|
|
* contained in the directory.
|
|
|
|
*/
|
2015-09-30 12:03:46 +02:00
|
|
|
char directory_name[OBIDMS_COLUMN_MAX_NAME+1]; /**< The name of the directory
|
2015-11-09 15:06:02 +01:00
|
|
|
* containing the column.
|
|
|
|
*/
|
2015-06-26 17:53:03 +02:00
|
|
|
} OBIDMS_column_directory_t, *OBIDMS_column_directory_p;
|
2015-06-23 18:35:34 +02:00
|
|
|
|
|
|
|
|
2017-10-26 18:58:48 +02:00
|
|
|
/**
|
|
|
|
* Function building the column directory name from an OBIDMS column name.
|
|
|
|
*
|
|
|
|
* The function builds the directory name corresponding to an OBIDMS column directory.
|
|
|
|
* It checks also that the name is not too long.
|
|
|
|
*
|
|
|
|
* @warning The returned pointer has to be freed by the caller.
|
|
|
|
*
|
|
|
|
* @param column_name The name of the OBIDMS column.
|
|
|
|
*
|
|
|
|
* @returns A pointer to the OBIDMS column directory name.
|
|
|
|
* @retval NULL if an error occurred.
|
|
|
|
*
|
|
|
|
* @since June 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
|
|
|
char* obi_build_column_directory_name(const char* column_name);
|
|
|
|
|
|
|
|
|
2015-09-30 12:03:46 +02:00
|
|
|
/**
|
|
|
|
* @brief Checks if an OBIDMS column directory exists.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @param dms A pointer to an OBIDMS as returned by obi_create_dms() or obi_open_dms().
|
|
|
|
* @param column_name A pointer to a C string containing the name of the column.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @returns An integer value indicating the status of the column directory.
|
|
|
|
* @retval 1 if the directory exists.
|
|
|
|
* @retval 0 if the directory does not exist.
|
|
|
|
* @retval -1 if an error occurred.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-06-26 17:53:03 +02:00
|
|
|
* @see obi_close_column_directory()
|
2015-06-23 18:35:34 +02:00
|
|
|
* @since June 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
2015-06-26 17:53:03 +02:00
|
|
|
int obi_column_directory_exists(OBIDMS_p dms, const char* column_name);
|
2015-06-23 18:35:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-26 17:53:03 +02:00
|
|
|
* @brief Creates a new OBIDMS column directory instance.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-06-26 17:53:03 +02:00
|
|
|
* A new OBIDMS column directory is created. This function checks
|
2015-06-23 18:35:34 +02:00
|
|
|
* if a directory with this name does not already exist
|
2015-06-26 17:53:03 +02:00
|
|
|
* before creating the new column directory.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @param dms A pointer to an OBIDMS as returned by obi_create_dms() or obi_open_dms().
|
|
|
|
* @param column_name A pointer to a C string containing the name of the column.
|
2015-06-23 18:35:34 +02:00
|
|
|
* The actual directory name used to store the column will be
|
|
|
|
* `<column_name>.obicol`.
|
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @returns A pointer to an OBIDMS column directory structure describing the newly created
|
|
|
|
* directory.
|
|
|
|
* @retval NULL if an error occurred.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-06-26 17:53:03 +02:00
|
|
|
* @see obi_close_column_directory()
|
2015-06-23 18:35:34 +02:00
|
|
|
* @since June 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
2015-06-26 17:53:03 +02:00
|
|
|
OBIDMS_column_directory_p obi_create_column_directory(OBIDMS_p dms, const char* column_name);
|
2015-06-23 18:35:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-26 17:53:03 +02:00
|
|
|
* @brief Opens an existing OBIDMS column directory instance.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @param dms A pointer to an OBIDMS as returned by obi_create_dms() or obi_open_dms().
|
|
|
|
* @param column_name A pointer to a C string containing the name of the column.
|
2015-06-23 18:35:34 +02:00
|
|
|
* The actual directory name used to store the column is
|
|
|
|
* `<column_name>.obicol`.
|
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @returns A pointer to the OBIDMS column directory structure describing the directory.
|
|
|
|
* @retval NULL if an error occurred.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-06-26 17:53:03 +02:00
|
|
|
* @see obi_close_column_directory()
|
2015-06-23 18:35:34 +02:00
|
|
|
* @since June 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
2015-06-26 17:53:03 +02:00
|
|
|
OBIDMS_column_directory_p obi_open_column_directory(OBIDMS_p dms, const char* column_name);
|
2015-06-23 18:35:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-26 17:53:03 +02:00
|
|
|
* @brief Opens or creates a new OBIDMS column directory instance.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-06-26 17:53:03 +02:00
|
|
|
* If the directory already exists, this function opens it, otherwise it
|
|
|
|
* creates a new column directory.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @param dms A pointer to an OBIDMS as returned by obi_create_dms() or obi_open_dms().
|
|
|
|
* @param column_name A pointer to a C string containing the name of the column.
|
2015-06-23 18:35:34 +02:00
|
|
|
* The actual directory name used to store the column is
|
|
|
|
* `<column_name>.obicol`.
|
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @returns A pointer to the OBIDMS column directory structure describing the directory.
|
|
|
|
* @retval NULL if an error occurred.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
|
|
|
* @since June 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
2015-06-26 17:53:03 +02:00
|
|
|
OBIDMS_column_directory_p obi_column_directory(OBIDMS_p dms, const char* column_name);
|
2015-06-23 18:35:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-26 17:53:03 +02:00
|
|
|
* @brief Closes an opened OBIDMS column directory instance.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @param column_directory A pointer to an OBIDMS column directory as returned by
|
|
|
|
* obi_create_column_directory() or obi_open_column_directory().
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-09-30 12:03:46 +02:00
|
|
|
* @returns An integer value indicating the success of the operation. Even on
|
|
|
|
* error, the `OBIDMS_column_directory` structure is freed.
|
|
|
|
* @retval 0 on success.
|
|
|
|
* @retval -1 if an error occurred.
|
2015-06-23 18:35:34 +02:00
|
|
|
*
|
2015-06-26 17:53:03 +02:00
|
|
|
* @see obi_create_column_directory()
|
|
|
|
* @see obi_open_column_directory()
|
2015-06-23 18:35:34 +02:00
|
|
|
* @since June 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
2015-06-26 17:53:03 +02:00
|
|
|
int obi_close_column_directory(OBIDMS_column_directory_p column_directory);
|
2015-06-23 18:35:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* OBIDMSCOLUMNDIR_H_ */
|