#ifndef FILE_T_H #define FILE_T_H #include /* md5sum */ #include "exception_t.h" typedef enum filepath_t { FILEPATH_ABSOLUTE, FILEPATH_RELATIVE, FILEPATH_HOME } filepath_t; /** * Wrapper to file */ typedef struct file_t { char *name; /**< Absolute path to file */ unsigned char hash[MD5_DIGEST_LENGTH]; /**< MD5sum hash */ char *hash_str; /**< MD5sum hash as char* */ filepath_t fp; } file_t; /** * @brief Initialise file_t * Adds $HOME to @filename and sets MD5 strings to NULL * @param filename Relative path () to file * @param e Exception * @return Pointer to file_t */ file_t* file_init(const char *filename, filepath_t FILEPATH, exception_t *e); /** * Destroy file_t * @param Pointer to file_t */ void file_close(file_t *file); /** * Generate MD5sum hash from file * @return MD5sum hash of file */ unsigned char* file_md5_gen(file_t *f, exception_t *e); /** * Convert MD5sum hash to string * @param md5 MD5sum hash * @return NULL-terminated string */ char* file_md5_str(file_t *f, exception_t *e); char* file_abs(const file_t *f); #endif