#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>
#include "core.h"
Go to the source code of this file.
|
|
#define | CT_OWNER 1 << 1 |
| |
|
#define | CT_PERM 1 << 2 |
| |
|
| int | copy2 (const char *src, const char *dest, unsigned op) |
| |
◆ copy2()
| int copy2 |
( |
const char * | src, |
|
|
const char * | dest, |
|
|
unsigned | op ) |
Copy a single file
if (
copy2(
"/source/path/example.txt",
"/destination/path/example.txt", CT_PERM | CT_OWNER)) {
fprintf(stderr, "Unable to copy file\n");
exit(1);
}
int copy2(const char *src, const char *dest, unsigned op)
- Parameters
-
| src | source file path |
| dest | destination file path |
| op | CT_OWNER (preserve ownership) |
| op | CT_PERM (preserve permission bits) |
- Returns
- 0 on success, -1 on error