aboutsummaryrefslogtreecommitdiff
path: root/include/copy.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/copy.h')
-rw-r--r--include/copy.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/copy.h b/include/copy.h
index 9e8bc11..5a53d7d 100644
--- a/include/copy.h
+++ b/include/copy.h
@@ -1,3 +1,4 @@
+//! @file copy.h
#ifndef OMC_COPY_H
#include <stdio.h>
@@ -12,8 +13,49 @@
#define CT_OWNER 1 << 1
#define CT_PERM 1 << 2
+/**
+ * Recursively copy a directory, or a single file
+ *
+ * ```c
+ * if (copytree("/source/path", "/destination/path", CT_PERM | CT_OWNER)) {
+ * fprintf(stderr, "Unable to copy files\n");
+ * exit(1);
+ * }
+ * ```
+ *
+ * @param srcdir source file or directory path
+ * @param destdir destination directory
+ * @param op CT_OWNER (preserve ownership)
+ * @param op CT_PERM (preserve permission bits)
+ * @return 0 on success, -1 on error
+ */
int copytree(const char *srcdir, const char *destdir, unsigned op);
+
+/**
+ * Create all leafs in directory path
+ * @param _path directory path to create
+ * @param mode mode_t permissions
+ * @return
+ */
int mkdirs(const char *_path, mode_t mode);
+
+/**
+ * Copy a single file
+ *
+ * ```c
+ * if (copy2("/source/path/example.txt", "/destination/path/example.txt", CT_PERM | CT_OWNER)) {
+ * fprintf(stderr, "Unable to copy file\n");
+ * exit(1);
+ * }
+ * ```
+ *
+ *
+ * @param src source file path
+ * @param dest destination file path
+ * @param op CT_OWNER (preserve ownership)
+ * @param op CT_PERM (preserve permission bits)
+ * @return 0 on success, -1 on error
+ */
int copy2(const char *src, const char *dest, unsigned op);
#endif // OMC_COPY_H \ No newline at end of file