From: David VaĊĦek Date: Fri, 19 Mar 2021 15:45:03 +0000 (+0100) Subject: contrib: copy_file() -- make it recognisable, that it is the source file that doesn... X-Git-Tag: v3.1.0~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e2d899ce87c7bb89ee307f00fe787aac16f92ee;p=thirdparty%2Fknot-dns.git contrib: copy_file() -- make it recognisable, that it is the source file that doesn't exist Not being used so far. --- diff --git a/src/contrib/files.c b/src/contrib/files.c index 7f24426f65..93e045ddcd 100644 --- a/src/contrib/files.c +++ b/src/contrib/files.c @@ -151,7 +151,7 @@ int copy_file(const char *dest, const char *src) FILE *from = fopen(src, "r"); if (from == NULL) { - ret = knot_map_errno(); + ret = errno == ENOENT ? KNOT_EFILE : knot_map_errno(); goto done; } diff --git a/src/contrib/files.h b/src/contrib/files.h index c8e245752f..5d7ed0efb8 100644 --- a/src/contrib/files.h +++ b/src/contrib/files.h @@ -44,5 +44,8 @@ int open_tmp_file(const char *path, char **tmp_name, FILE **file, mode_t mode); /*! * Copies a file, possibly overwriting existing one, as an atomic operation. + * + * \return KNOT_EOK on success, KNOT_EFILE if the source file doesn't exist, + * \or other KNOT_E* values in case of other errors. */ int copy_file(const char *dest, const char *src);