]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
contrib: copy_file() -- make it recognisable, that it is the source file that doesn...
authorDavid Vašek <david.vasek@nic.cz>
Fri, 19 Mar 2021 15:45:03 +0000 (16:45 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Tue, 11 May 2021 18:14:38 +0000 (20:14 +0200)
Not being used so far.

src/contrib/files.c
src/contrib/files.h

index 7f24426f6556c4879af59d48aac8f1e88623ac59..93e045ddcd655a4033f4b8a532e024bdbcfcea1c 100644 (file)
@@ -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;
        }
 
index c8e245752f4f65a83a25e969409422846a40b491..5d7ed0efb80d42510d6148c63ec0f9434df385c8 100644 (file)
@@ -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);