From 6245acea848392861c2cd175d0292ef6b4f6638e Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Mon, 19 Nov 2007 18:29:26 +0000 Subject: [PATCH] Add API to delete enroll data --- libfprint/data.c | 43 +++++++++++++++++++++++++++++++++++++++++++ libfprint/fprint.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/libfprint/data.c b/libfprint/data.c index 79d161d..c36f94d 100644 --- a/libfprint/data.c +++ b/libfprint/data.c @@ -25,6 +25,7 @@ #include #include +#include #include "fp_internal.h" @@ -357,6 +358,28 @@ API_EXPORTED int fp_print_data_load(struct fp_dev *dev, return 0; } +/** \ingroup print_data + * Removes a stored print from disk previously saved with fp_print_data_save(). + * \param dev the device that the print belongs to + * \param finger the finger of the file you are deleting + * \returns 0 on success, negative on error + */ +API_EXPORTED int fp_print_data_delete(struct fp_dev *dev, + enum fp_finger finger) +{ + int r; + gchar *path = get_path_to_print(dev, finger); + + fp_dbg("remove finger %d at %s", finger, path); + r = g_unlink(path); + g_free(path); + if (r < 0) + fp_dbg("unlink failed with error %d", r); + + /* FIXME: cleanup empty directory */ + return r; +} + /** \ingroup print_data * Attempts to load a stored print based on a \ref dscv_print * "discovered print" record. @@ -639,3 +662,23 @@ API_EXPORTED enum fp_finger fp_dscv_print_get_finger(struct fp_dscv_print *print return print->finger; } +/** \ingroup dscv_print + * Removes a discovered print from disk. After successful return of this + * function, functions such as fp_dscv_print_get_finger() will continue to + * operate as before, however calling fp_print_data_from_dscv_print() will + * fail for obvious reasons. + * \param print the discovered print to remove from disk + * \returns 0 on success, negative on error + */ +API_EXPORTED int fp_dscv_print_delete(struct fp_dscv_print *print) +{ + int r; + fp_dbg("remove at %s", print->path); + r = g_unlink(print->path); + if (r < 0) + fp_dbg("unlink failed with error %d", r); + + /* FIXME: cleanup empty directory */ + return r; +} + diff --git a/libfprint/fprint.h b/libfprint/fprint.h index 20f0545..639c963 100644 --- a/libfprint/fprint.h +++ b/libfprint/fprint.h @@ -80,6 +80,7 @@ void fp_dscv_prints_free(struct fp_dscv_print **prints); uint16_t fp_dscv_print_get_driver_id(struct fp_dscv_print *print); uint32_t fp_dscv_print_get_devtype(struct fp_dscv_print *print); enum fp_finger fp_dscv_print_get_finger(struct fp_dscv_print *print); +int fp_dscv_print_delete(struct fp_dscv_print *print); /* Device handling */ struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev); @@ -199,6 +200,7 @@ int fp_print_data_load(struct fp_dev *dev, enum fp_finger finger, int fp_print_data_from_dscv_print(struct fp_dscv_print *print, struct fp_print_data **data); int fp_print_data_save(struct fp_print_data *data, enum fp_finger finger); +int fp_print_data_delete(struct fp_dev *dev, enum fp_finger finger); void fp_print_data_free(struct fp_print_data *data); size_t fp_print_data_get_data(struct fp_print_data *data, unsigned char **ret); struct fp_print_data *fp_print_data_from_data(unsigned char *buf,