add function fc_delete_file_ex

pull/37/head
YuQing 2019-12-25 15:20:07 +08:00
parent ad57015174
commit 12dde730c8
3 changed files with 40 additions and 0 deletions

View File

@ -4,6 +4,7 @@ Version 1.43 2019-12-25
system is the deprecated function in iOS 11
* correct function skiplist_iterator in skiplist.h
* add buffered_file_writer.[hc]
* add function fc_delete_file_ex
Version 1.42 2019-12-03
* add function get_gzip_command_filename

View File

@ -2866,3 +2866,29 @@ const char *get_gzip_command_filename()
return "gzip";
}
}
int fc_delete_file_ex(const char *filename, const char *caption)
{
int result;
if (unlink(filename) == 0)
{
return 0;
}
result = errno != 0 ? errno : ENOENT;
if (result == ENOENT)
{
result = 0;
}
else
{
logError("file: "__FILE__", line: %d, "
"unlink %s file: %s fail, "
"errno: %d, error info: %s",
__LINE__, caption, filename,
result, STRERROR(result));
}
return result;
}

View File

@ -856,6 +856,19 @@ char *resolve_path(const char *from, const char *filename,
*/
const char *get_gzip_command_filename();
/** delete file
* parameters:
* filename: the filename to delete
* caption: the caption of this filename
* return: error no, 0 success, != 0 fail
*/
int fc_delete_file_ex(const char *filename, const char *caption);
static inline int fc_delete_file(const char *filename)
{
return fc_delete_file_ex(filename, "");
}
#ifdef __cplusplus
}
#endif